<template>
  <div class="c-bg-sgray">
    <pay-password v-show="showPassword" :price="totalAllPrice" @hidePwd="hidePwd" @confirmPwd="confirmPwd"></pay-password>
    <div class="thme-bg-gradient1 c-ph24 c-pt48 c-p c-pb20">
      <div class="c-text-hidden" :class="deliverType == 3 ? 'c-br-bl10 c-br-br10' : 'c-br10'">
        <div class="c-flex-row c-aligni-end c-justify-sb c-textAlign-c" v-if="deliverType == 3">
          <div v-for="(item, index) in typeList" :key="index" class="c-w50"
            :class="[typeIndex == index + 1 ? 'c-fs28 c-fw-b c-fc-xblack c-bg-white c-pv24' : 'c-fs24 c-fc-white theme-bg c-pv20', typeIndex == 1 && index == 0 ? ' typeIndex0' : typeIndex == 2 && index == 1 ? ' typeIndex1' : '', index == 0 ? ' c-br-tl8 c-br-tr4' : ' c-br-tl4 c-br-tr8']"
            @click="changeType(index + 1)">{{ item.name }}</div>
        </div>
        <!-- 正常物流流程 -->
        <div v-if="deliverType == 1 || (deliverType == 3 && typeIndex == 1)" class="c-bg-white c-ph24 c-pb24">
          <div class="c-flex-row c-aligni-center">
            <div>
              <span class="iconfont c-mr12">&#xe6e2;</span>
            </div>
            <div class="c-w100">
              <div class="c-fc-xblack c-mt-2" :class="(presale && moneyType == 2) ? 'c-pt24' : 'c-bd-b1 c-pv24'" @click="clickSelectAddress(addressInfo.no)">
                <div class="c-flex-row c-justify-sb c-aligni-center c-fs24 c-fc-xblack">
                  <div v-if="addressInfo.name">
                    <span>收货人：{{ addressInfo.name }}</span>
                  </div>
                  <div v-else>请选择收货地址</div>
                  <div>
                    <span class="c-mr12">{{ addressInfo.mobile }}</span>
                  </div>
                </div>
                <div class="c-fs20 c-lh28 c-mt20 c-ww460 c-text-ellipsis1" v-if="addressInfo.addrId">
                  <span>{{ addressInfo.city }}</span>
                  <span>{{ addressInfo.area }}</span>
                  <span>{{ addressInfo.address }}</span>
                </div>
              </div>
            </div>
            <div>
              <span class="iconfont c-fs18 c-fc-gray">&#xe60e;</span>
            </div>
          </div>
          <div class="c-fs24 c-fc-sblack c-flex-row c-aligni-center c-justify-end c-lh34 c-pt24" v-if="!(presale && moneyType == 2)">
            <span class="c-flex-grow1 c-w0 c-fc-xblack">运费</span>
            <div v-if="totalPostage != null && !onlyValuationMethod" class="c-fs26 theme-fc">
              <span v-if="totalPostage * 1 > 0">{{ "￥" | iosPriceFilter }}</span>
              {{ totalPostage * 1 > 0 ? totalPostage : "包邮" }}
            </div>
            <span v-else-if="onlyValuationMethod" class="c-fs26 theme-fc">到付</span>
          </div>
        </div>
        <!-- 线下自提流程 -->
        <div v-if="deliverType == 2 || (deliverType == 3 && typeIndex == 2)" class="c-fc-xblack c-bd-b1 c-pv24 c-ph24 c-bg-white c-mt-2">
          <div class="theme-fc c-fs20 c-lh-28 c-mb20 c-flex-row c-aligni-center" v-if="(isExpressDeliver -= 1 && shopList[0] && shopList[0].isMallOfflineDeliver == 1)">
            <span class="iconfont icon-tanhao c-mr10"></span>该商品仅支持线下自提
          </div>
          <div class="c-flex-column c-justify-sb c-aligni-center c-fs24 c-fc-xblack c-mb20 c-bd-b1 c-pb20">
            <div class="c-flex-row c-aligni-center c-justify-sb c-w100" :class="nearOffline ? 'c-mb20' : ''" @click="goOfflineList">
              <div>
                <span class="iconfont c-mr12">&#xe8fe;</span>
                <span v-if="nearOffline">{{ nearOffline.modName }}</span>
                <span v-else>请选择提取点</span>
              </div>
              <span class="iconfont c-fc-sgray c-fs28">&#xe908;</span>
            </div>
            <div class="c-flex-row c-aligni-center c-w100 c-fs20 c-lh28" v-if="nearOffline">
              <span class="c-mr12">地址：{{ nearOffline.address }}</span>
            </div>
          </div>
          <div class="c-fs24 c-lh34 c-flex-row c-aligni-center c-justify-sb" v-if="offlineAddressInfo.name != '' && offlineAddressInfo.mobile != ''" @click="showInfo">
            <span>提货人</span>
            <div>
              <span>{{ offlineAddressInfo.name }}</span>
              <span>{{ offlineAddressInfo.mobile }}</span>
              <span class="iconfont c-fc-sgray c-fs28">&#xe908;</span>
            </div>
          </div>
          <div class="c-fs24 c-lh34 c-flex-row c-aligni-center c-justify-sb c-fc-sblack" v-else @click="showInfo">
            <span>请添加提货人信息</span>
            <span class="iconfont c-fc-sgray c-fs28">&#xe908;</span>
          </div>
        </div>
      </div>
    </div>
    <div class="c-ph24 c-pb20">
      <div class="c-ph24 c-bg-white c-fs24 c-br10">
        <div class="c-bd-b1 c-pv20 c-flex-row c-aligni-center">
          <span class="iconfont c-fc-xblack c-fw-b">&#xe6d2;</span>
          <span class="c-pl12">购物清单</span>
        </div>
        <div v-for="(item, index) in shopList" :key="item.no" class="c-pt24 c-pb20" :class="shopList && shopList.length == (index + 1) ? '' : 'c-bd-b1'">
          <div class="c-flex-row">
            <div class="c-ww180 c-maxh180 c-text-hidden c-br8">
              <img class="c-w100 imgCloseBig c-br8" :src="$addXossFilter(item.avatar, require('@/assets/defult270.png'))" />
            </div>
            <div class="c-pl20 c-flex-grow1 c-w0 c-flex-column c-justify-sb">
              <div>
                <div class="c-fs24 c-fc-xblack c-text-ellipsis1 c-lh32"><span v-if="presale" class="c-fs20 theme-bd1 theme-fc c-ph4 c-pv2 c-br4 c-mr10">预售</span>{{ item.name }}</div>
                <div class="c-fs20 c-fc-gray c-mt20" v-if="item.shopSpecInfo">
                  <collapse :default-height="52">
                    <div>规格：{{ item.shopSpecInfo }}</div>
                  </collapse>
                </div>
              </div>
              <div class="c-fs20 c-fc-gray c-text-ellipsis1 c-mt20" v-if="item.minOrderQuantity && item.minOrderQuantity > 1 && presale == null">起售：{{ item.minOrderQuantity }}</div>
              <div class="c-flex-row c-fs24 c-aligni-center">
                <span v-if="item.isFlashSales || item.isCollage" class="c-fs16 theme-bg c-fc-white c-textAlign-c c-br4 c-hh24 c-lh28 c-ph4">{{ item.isFlashSales ? (Number(item.defaultPrice) == 0 ? '限时免费' : '限时折扣') : "拼团" }}</span>
                <span :class="item.isFlashSales || item.isCollage ? 'c-pl16' : ''" v-if="!item.isIntegral">{{ "￥" | iosPriceFilter }}{{(item.defaultPrice * 1) | toMyFixed2}}</span>
                <span class="theme-fc" v-if="item.isIntegral">{{ item.defaultPrice * 1 }}{{customPointName}}</span>
                <span class="c-fc-gray c-text-decoration-through c-pl16 c-flex-grow1 c-w0" v-if="item.originalPrice * 1 > 0 && item.originalPrice * 1 > item.defaultPrice * 1">{{ "￥" | iosPriceFilter }}{{(item.originalPrice * 1) | toMyFixed2}}</span>
                <span class="c-fc-gray c-text-decoration-through c-pl16 c-flex-grow1 c-w0" v-else-if="item.isExchange && item.realPrice && item.realPrice * 1 > 0">{{ "￥" | iosPriceFilter }}{{(item.realPrice * 1) | toMyFixed2}}</span>
              </div>
            </div>
          </div>
          <div class="c-pt48 c-flex-row" v-if="!item.isExchange && !item.isFromChain && !item.isCollage && !item.isFlashSales && !isTurntable && !cashBack && !isInBargain && !presale && item.dignityDis">
            <div class="c-flex-grow1 c-w0">
              折后价
              <span class="c-fs22 c-fc-gray" v-if="vipType >= 2 && item.vipDiscountType == 1">({{ discountServer(item, vipType) }})</span>
            </div>
            <div class="c-fs24 theme-fc" v-if="vipType == 2">{{ "￥" | iosPriceFilter }}{{ (item.vipDiscountType && item.vipDiscountType == 2 ? item.vipDiscount : item.price * 1 * (item.vipDiscount / 100)) | toMyFixed2 }}</div>
            <div class="c-fs24 theme-fc" v-else-if="vipType == 4">{{ "￥" | iosPriceFilter }}{{ (item.vipDiscountType && item.vipDiscountType == 2 ? item.svipDiscount : item.price * 1 * (item.svipDiscount / 100)) | toMyFixed2 }}</div>
            <div class="c-fs24 theme-fc" v-else>{{ "￥" | iosPriceFilter }}{{ (item.vipDiscountType && item.vipDiscountType == 2 ? item.commonProdInfo.agentDiscount : item.price * 1 * (item.commonProdInfo.agentDiscount / 100)) | toMyFixed2 }}</div>
          </div>
          <div class="c-pt48 c-flex-row" v-if="!(cashBack && getUseMcbgId) && !isInBargain && item.isFromChain && item.orderBonus && Number(item.chainDiscount) > 0">
            <div class="c-flex-grow1 c-w0">{{chainInfo.isReorder && item.isReorder ? '复购' : '购买'}}优惠</div>
            <div class="c-fs24 theme-fc">-{{ "￥" | iosPriceFilter }}{{ Number(item.chainDiscount) | toMyFixed2 }}</div>
          </div>
          <div class="c-pt48 c-flex-row">
            <div class="c-flex-grow1 c-w0">
              商品数量
              <span class="c-fs22 c-fc-gray" v-if="item.isFlashSales && !item.noLimit">(限购{{ item.salesStock }}件)</span>
              <span class="c-fs22 c-fc-gray" v-if="item.isCollage && !item.noLimit">(限购{{ item.collageStock }}件)</span>
            </div>
            <shop-number class="c-mr-12" v-if="!item.mcbId" :min="isInBargain ? item.stock : item.minOrderQuantity * 1 > 1 ? item.minOrderQuantity : 1" :max="shopNumberMax(item)"
              :inputNum="item.quantity" :itemIndex="index" :isLimitBuy="item.limitType" :purchasedNum="item.purchasedNum" :limitNumber="item.limitNumber" @outMaxNum="outMaxNum" @subNum="subNum"
              @addNum="addNum" @inputChange="inputChange" @finishInput="finishInput"></shop-number>
            <shop-number class="c-mr-12" v-else :min="item.minOrderQuantity * 1 > 1 ? item.minOrderQuantity : 1" :max="shopNumberMax(item)" :inputNum="item.quantity" :itemIndex="index"
              :isLimitBuy="item.limitType" :purchasedNum="item.purchasedNum" :limitNumber="item.limitNumber" @outMaxNum="outMaxNum" @subNum="cashListSubNum" @addNum="cashListAddNum"
              @inputChange="cashListInputChange" @finishInput="cashListFinishInput"></shop-number>
          </div>
          <div class="c-pt48 c-flex-row" v-if="item.totalHadBargainPrice && item.totalHadBargainPrice > 0">
            <div class="c-flex-grow1 c-w0">
              砍价优惠
            </div>
            <span class="c-fs22 c-fc-xbalck">-{{ "￥" | iosPriceFilter }}{{item.totalHadBargainPrice}}</span>
          </div>
          <div class="c-pt48 c-flex-row" v-if="item.valuationMethod && item.valuationMethod == 2 && !onlyValuationMethod">
            <span class="c-fs22 c-fc-gray c-flex-grow1 c-w0">运费</span>
            <span class="c-fs22 c-fc-gray">到付</span>
          </div>
          <div v-if="presale">
            <div class="c-flex-row c-aligni-center c-pl24 c-pv22" :class="moneyType == 2 ? 'theme-fc' : 'c-fc-xblack'">
              <div class="c-fs22"><i class="c-ww12 c-hh12 c-brp50 c-mr8 c-inlineblack c-p" :class="moneyType == 2 ? 'theme-bg' : 'c-bg-ccc'"><i class="line1" :class="moneyType == 2 ? 'theme-bg' : 'c-bg-ccc'"></i></i>定金</div>
              <div class="c-ml20 c-w0 c-flex-grow1 c-textAlign-r">{{'￥' | iosPriceFilter}}{{presale.deposit * item.quantity | toMyFixed2}}</div>
            </div>
            <div class="c-flex-row c-aligni-start c-pl24 c-pt22" :class="moneyType == 3 ? 'theme-fc' : 'c-fc-xblack'">
              <div class="c-fs22"><i class="c-ww12 c-hh12 c-brp50 c-mr8 c-inlineblack c-p" :class="moneyType == 3 ? 'theme-bg' : 'c-bg-ccc'"><i class="line2" :class="moneyType == 3 ? 'theme-bg' : 'c-bg-ccc'"></i></i>尾款</div>
              <div class="c-ml20 c-w0 c-flex-grow1 c-textAlign-r">
                <div class="c-fs24">{{'￥' | iosPriceFilter}}{{((presale.aPrice - presale.deposit) * item.quantity) | toMyFixed2}}</div>
                <div class="c-fs22 c-mt8">{{getLeaveTime}} 支付尾款</div>
              </div>
            </div>
          </div>
          <div class="c-flex-row c-aligni-center c-pt30">
            <span class="c-flex-grow1 c-w0 c-textAlign-r c-pr24 c-fs20 c-fc-gray">共{{ item.quantity }}件</span>
            <span>小计：</span>
            <span class="c-fs26 theme-fc" v-if="item.isIntegral">{{ totalAllPrice }}{{customPointName}}</span>
            <span class="c-fs26 theme-fc" v-else>{{ "￥" | iosPriceFilter }}{{ !(item.isFromChain && item.orderBonu) ? item.totalPrice : item.chainTotalPrice }}</span>
          </div>
        </div>
        <!-- 关联售卖列表 -->
        <div v-if="relData && relData.length > 0">
          <div class="c-pt24 c-fs24 c-fc-xblack">套餐</div>
          <mall-package-list :relData="relData" :templateStyle="2"></mall-package-list>
        </div>
        <div class="c-mt20 c-pb22" v-if="cashBack != null && getUseMcbgId != null && (getUseMcbgId.isSendProd == 1 || getUseMcbgId.isSendPoints == 1 || getUseMcbgId.isSendDiscount == 1)">
          <p class="c-fs24 c-fc-xblack">赠送</p>
          <div v-if="getUseMcbgId.isSendProd == 1">
            <div v-for="(sItem, sIndex) in getUseMcbgId.sendProdList" :key="sIndex" class="c-flex-row c-aligni-center c-mt24" :class="sIndex == getUseMcbgId.sendProdList.length - 1 ? '' : 'c-mb26'">
              <div class="c-ww72 c-hh72 c-text-hidden c-br8">
                <img class="c-w100 imgCloseBig c-br8" :src="$addXossFilter(sItem.cover, require('@/assets/defult270.png'))" />
              </div>
              <div class="c-pl20 c-flex-grow1 c-w0 c-flex-column c-justify-sb c-hh72">
                <div class="c-fs22 c-fc-xblack c-text-ellipsis1">{{ sItem.prodName }}</div>
                <div class="c-flex-row c-justify-sb c-algni-center">
                  <div class="c-fs24 c-fc-gray" v-if="sItem.stock > 0">
                    x{{ sItem.stock - sItem.number * getCashBackLoop >= 0 ? sItem.number * getCashBackLoop : sItem.stock }}
                  </div>
                  <div class="c-fs18 c-fc-gray c-ph4 c-pv2 c-bg c-bg-f457" v-else>已赠完</div>
                </div>
              </div>
            </div>
          </div>
          <div class="c-flex-row c-aligni-start c-justify-sb c-mt24" v-if="getUseMcbgId.isSendDiscount == 1">
            <div class="c-fs22 c-fc-gray c-ww136">[送优惠券]</div>
            <div class="c-w0 c-flex-grow1">
              <div class="c-fs22 c-lh32 c-fc-xblack" :class="sIndex == getUseMcbgId.sendDiscountList.length - 1 ? '' : 'c-mb20'" v-for="(sItem, sIndex) in getUseMcbgId.sendDiscountList" :key="sIndex">
                <span class="c-fs18 c-fc-gray c-ph4 c-pv2 c-bg c-bg-f457 c-mr12" v-if="sItem.stock == 0">已赠完</span>
                <span v-else>送{{ sItem.stock - sItem.number * getCashBackLoop >= 0 ? sItem.number * getCashBackLoop : sItem.stock }}张</span> {{ sItem.name }}
              </div>
            </div>
          </div>
          <div class="c-flex-row c-aligni-start c-justify-sb c-mt24" v-if="getUseMcbgId.isSendPoints == 1">
            <div class="c-fs22 c-fc-gray c-ww136">[送{{customPointName}}]</div>
            <div class="c-w0 c-fs22 c-flex-grow1">送{{ getUseMcbgId.points * getCashBackLoop }}{{customPointName}}</div>
          </div>
        </div>
      </div>
      <div class="c-bg-white c-br10 c-mt20 c-ph24">
        <div class="c-fs24 c-flex-row c-aligni-center c-hh80 c-bd-b1">
          <span>买家留言：</span>
          <input type="text" v-model="msg" class="input-message c-flex-grow1 c-w0  c-fs24 c-fc-xblack c-textAlign-r" placeholder="请输入备注信息" />
        </div>
        <div v-if="isMail" class="c-fs24 c-flex-row c-aligni-center c-hh80 c-bd-b1">
          <span>邮箱：</span>
          <input type="text" v-model="email" class="input-message c-flex-grow1 c-w0  c-fs24 c-fc-xblack c-textAlign-r" placeholder="请输入邮箱" />
        </div>
        <div @click="clickShowCoupon"
          v-if="companyAuth.enableRedeemCode == 1 && isIntegral == 0 && (isTurntable == false || livePrizeInfo || isPayAward == false || isGiftRelate == false) && cashBack == null && !isInBargain && !(presale && (moneyType == 2 || (moneyType == 3 && enableDeduction == 0)))"
          class="c-bd-b1 c-flex-row c-aligni-center c-hh80">
          <div class="c-flex-grow1 c-w0 c-fs24 c-lh">优惠券</div>
          <div v-if="couponList.length > 0" class="c-flex-row c-aligni-center">
            <div class="c-fs24 theme-fc c-mr12" v-if="choosedCouponPrice > 0">已优惠：{{ choosedCouponPrice }}元</div>
            <div class="iconfont c-fs18 c-fc-gray">&#xe60e;</div>
          </div>
          <div v-else class="c-flex-row c-aligni-center c-fs24 c-fc-gray">
            无可用优惠券
          </div>
        </div>
        <!-- 积分 -->
        <div class="c-fs24 c-flex-row c-hh80 c-bd-b1" v-if="isIntegral == 1">
          <span class="c-flex-shrink0 c-inlineblack">{{customPointName}}详情：</span>
          <span v-if="isIntegral == 1" class="c-fs24 c-fc-gray">需要{{ totalAllPrice }}{{customPointName}}，当前您剩余{{ pMallGood.userPoint * 1 }}{{customPointName}} </span>
        </div>
        <div class="c-fs24 c-flex-row c-hh80 c-aligni-center c-bd-b1" v-if="isShowPointsSwitch">
          <span>{{ companyAuth.integrateName1 }}抵扣</span>
          <span class="c-flex-grow1 c-w0 c-fs24 c-fc-gray">（{{ totalPoints }}{{ companyAuth.integrateName1 }}抵扣{{ "￥" | iosPriceFilter }}{{ totalPointsPrice }}）</span>
          <x-switch :themeColor="$getThemeColor()" title="" v-model="userPoints"></x-switch>
        </div>
        <!-- 满减活动 -->
        <div class="c-fs24 c-flex-row c-aligni-center c-hh80 c-bd-b1" @click="showCashBack = true" v-if="cashBack != null && cashBack.reduce > 0">
          <span class="c-flex-grow1 c-w0 ">活动优惠</span>
          <div class="c-fs24 theme-fc c-flex-row c-aligni-center">
            <span class="c-fs16">-{{ "￥" | iosPriceFilter }}</span>
            <span v-if="cashBack && cashBack.reduce">{{ cashBackReduce }}</span>
            <span class="iconfont c-fs24 c-fc-gray">&#xe635;</span>
          </div>
        </div>
        <div v-if="isInvoice == 1 && isIntegral == 0" class="c-flex-row c-aligni-center c-fs24 c-hh80" @click="clickShowInvoice">
          <span class="c-flex-grow1 c-w0">是否需要开发票</span>
          <span class="c-fs24 c-fc-gray">{{ !invoiceInfo ? "不开发票" : "开发票" }}</span>
          <span class="iconfont c-fs18 c-fc-sgray">&#xe60e;</span>
        </div>
        <!-- 优惠券列表 -->
        <div class="c-w100 c-h" v-show="showCoup">
          <div class="masker" @click="closeCoupon"></div>
          <div class="content c-flex-column c-pb40 c-bg-coupon">
            <div class="c-flex-row c-flex-center c-w100 c-hh80 c-fs28 c-fc-xblack c-bg-white">选择优惠券</div>
            <div class="close" @click="closeCoupon"><span class="iconfont c-fs24 c-fc-gray">&#xe61b;</span></div>
            <div class="all-coupon-bg c-maxh600 c-ph24 c-pv30 c-contexty-scroll c-scroll-touch">
              <!-- 可用优惠券列表 -->
              <coupon-item-com v-for="(item, index) in couponList" :key="index" :couponInfo="item" :showFooter="false" @clickCouponItem="clickCoupon(index)" class="c-mb20">
                <div :class="index == choosedCouponIndex ? 'theme-fc' : 'c-fc-gray'" class="iconfont c-fs26 c-pa c-p-t64 c-p-r24">&#xe6b1;</div>
              </coupon-item-com>
            </div>
          </div>
        </div>
      </div>
    </div>
    <section class="c-pl24 c-pb20 c-fs20 theme-fc c-lh42" v-if="protocolInfo" @click="changeCheckAgreement">
      <i v-show="!isCheckAgreement" class="iconfont c-fs26 c-lh42 c-fc-gray c-pr16">&#xe872;</i>
      <i v-show="isCheckAgreement" class="iconfont c-fs26 c-lh42 c-fc-gray c-pr16">&#xe871;</i>
      <span class="c-fc-gray">已阅读并同意</span>
      <span @click.stop="clickProtocol(item)" v-for="(item, index) in protocolInfo" :key="index">《{{ item.name }}》</span>
    </section>
    <div class="shop-cart-bottom c-bg-white">
      <div class="c-pv15 c-mr24 c-flex-row c-aligni-center c-justify-end c-w100">
        <span class="c-fs24 c-fc-xblack c-pl26 c-flex-grow1  c-w0  c-textAlign-r">合计：</span>
        <span class="theme-fc c-fs28" v-if="isIntegral == 0">{{ "￥" | iosPriceFilter }}</span>
        <span class="theme-fc c-pr20 c-fs32 c-fw-b">{{ totalAllPrice }} {{ isIntegral == 1 ? customPointName : "" }}</span>
        <div class="theme-bg c-br36 c-fs24 c-lh-34 c-pv16 c-ph40 c-fc-white" @click="clickSettlement">{{ isIntegral == 1 ? "立即兑换" : "提交订单" }}</div>
      </div>
    </div>
    <open-modal :openModal="showCashBack" @closeModal="showCashBack = false">
      <div class="masker-content c-br-tl20 c-br-tr20">
        <div class="c-p">
          <div class="c-w100 c-textAlign-c c-fs28 c-pt24 c-fc-sblack">活动优惠</div>
          <i class="iconfont c-pa c-p-t30 c-p-r24 c-fc-sgray c-fs20 c-bg-f6 c-ww30 c-hh30 c-brp50 c-flex-row c-flex-center" @click="showCashBack = false">&#xe8fd;</i>
          <div class="c-ph24 c-mt80">
            <div class="c-fs22 c-fc-xblack c-mt12 c-flex-row c-aligni-center c-justify-sb c-pb24 c-mb24 c-bd-b1" v-if="cashBack != null">
              <div class="c-fs22 c-fc-xblack c-flex-row c-aligni-center">
                <span class="c-fc-lorange c-br2 tagBg c-pv2 c-ph4 c-fs18 c-mr12">满减送</span>
                <span v-if="cashBack.title" class="c-maxw400 c-text-ellipsis1">{{ cashBack.title }}</span>
              </div>
              <div class="c-fs22 c-fc-xblack">
                <span class="c-fs16">-{{ "￥" | iosPriceFilter }}</span>
                <span v-if="cashBack && cashBack.reduce">{{ cashBack.reduce }}</span>
              </div>
            </div>
            <div class=" c-flex-row c-aligni-center c-justify-end">
              <div class="c-fs22 c-fc-xblack">
                合计：
                <span class="c-fs16 theme-fc">-{{ "￥" | iosPriceFilter }}</span>
                <span class="theme-fc" v-if="cashBack && cashBack.reduce">{{ cashBack.reduce }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </open-modal>

    <!-- 开票 -->
    <invoice-modal ref="invoiceModal" :showInvoice="showInvoice" @getInvoice="getInvoice" @clickCloseModal="clickCloseModal"></invoice-modal>

    <open-modal :openModal="showAddressInfo" @closeModal="changeAddressInfo(0)">
      <div class="c-ph24 c-bg-white c-pt24 c-pb20 c-p c-br-tl8 c-br-tr8">
        <span class="iconfont c-fs20 c-pa c-p-r24 c-p-t32" @click="changeAddressInfo(0)">&#xe8fd;</span>
        <p class="c-fs26 c-lh36 c-fc-xblack c-textAlign-c">提货人信息</p>
        <input type="text" ref="name" :value="offlineAddressInfo.name" placeholder="请输入姓名" class="inputInfo c-fs24 c-lh34 c-bd0 c-pv20 c-fc-xblack c-bd-b1 c-w100" />
        <input type="text" ref="mobile" :value="offlineAddressInfo.mobile" placeholder="请输入联系电话" class="inputInfo c-fs24 c-lh34 c-bd0 c-pv20 c-fc-xblack c-bd-b1 c-w100" />
        <div class="c-fs24 c-fc-white c-br36 c-lh34 c-pv16 theme-bg c-textAlign-c c-mt20" @click="changeAddressInfo(1)">确定</div>
      </div>
    </open-modal>
    <pay-template v-if="isShowPay" :ckFrom="ckFrom.shopping" :balance="balance" :totalPrice="totalAllPrice * 1" :coinAmount="coinAmount" :totalCoin="totalCoin" :isCanUseGiftCard="isCanUseGiftCard"
      :enablePayMall="payConf ? (payConf.enablePayMall == 0 ? false : true) : true" :enableWxpay="!!(payConf.enableWxpay == 1)" @clickPayType="clickPayType" @closePay="closePay"></pay-template>
  </div>
</template>

<script>
import PayTemplate from "@/components/templates/common/pay/payTemplate.vue";
import PayPassword from "@/components/templates/common/pay/payPassword.vue";
import ShopNumber from "@/components/templates/shopNumber.vue";
import OpenModal from "@/components/templates/common/openModal.vue";
import { XSwitch } from "ckjrweb-mp-ui/src/components/index";
import { utilJs, wxUtilJs } from "@/utils/common.js";
import { checkEnableModule } from "@/utils/checkEnableModuleUtil.js";
import mallPackageList from "@/components/templates/shop/mallPackageList.vue";
import collapse from "@/components/templates/common/collapse.vue";
import InvoiceModal from "@/components/templates/invoiceModal.vue";
import couponItemCom from "@/components/templates/couponItemCom.vue";
import { mapState } from "vuex";
let goId = "";
// let berforPostage = 0;//记录邮费
let isClick = false;
let isWechatPaying = false;
let curScollTop = 0;
let curUserPoints = 0;
let givenPoints = 0; //支付赠送积分
let goodsType = 1; //判断商品购买类型 4:拼团 2:限时购 1:普通商品
let canUseCoupon = []; // 当前可用优惠券
let shopVipTotlaPrice = 0; //折后价
let isAutoChooseCoupon = false; // 是否自动选择优惠券
let isShowCashBackEnd = true; // 满减活动时间是否结束的弹窗展示
let shopAllList = []; // 满减商品+商品列表
let isGetOrder = 0;
let fromRoute = ""; // 从哪个页面跳转的路由
let hasPassword = 1; //是否已经设置过支付密码
// let isCanclePay = false; // 是否取消支付
let isCheckAgreement = 0; // -1未选择 0未勾选 1勾选
let isPayGiftCard = false; // 是否正在支付虚拟支付
export default {
  name: "ShopSettlement",
  components: {
    XSwitch,
    PayTemplate,
    PayPassword,
    ShopNumber,
    OpenModal,
    mallPackageList,
    collapse,
    InvoiceModal,
    couponItemCom
  },
  props: {
    fromPage: {
      type: String,
      default: "SHOP",
    },
    socialRoomId: {
      type: String,
      default: "",
    },
  },
  beforeRouteEnter(to, from, next) {
    console.log("---beforeRouteEnter---", to, from);
    fromRoute = window.location.href.split("#")[0] + "#" + from.fullPath;
    if (from.path.includes("/mall/shippingAddress/addressList") || from.path.includes("/mall/offlineSite/offlineSiteList")) {
      next();
    } else {
      next((vm) => {
        vm.initData();
        isCheckAgreement = -1;
        if (!(to.query.isGoldPlan && to.query.isGoldPlan == 1 && localStorage.getItem("shopPayBack"))) {
          vm.pathFrom = from.fullPath;
        }
      });
    }
  },
  beforeRouteLeave(to, from, next) {
    console.log("---beforeRouteLeave---", to, from);
    this.$cjConfirm.hide();
    if (!["/mall/shippingAddress/addressList", "/mall/offlineSite/offlineSiteList", "/homePage/form"].includes(to.path)) {
      if (this.livePrizeInfo) {
        this.$store.commit("live/setPrizeInfo", null);
      }
      next();
      return;
    }
    sessionStorage.setItem("shopBuyInfo", JSON.stringify(shopAllList));
    next();
  },
  data() {
    return {
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : "mb5_default",
      companyAuth: JSON.parse(localStorage.getItem("companyAuth")),
      customName: JSON.parse(localStorage.getItem("customName")),
      showInvoice: false, //开发票弹窗
      showPassword: false, //显示余额支付输入密码弹窗
      invoiceType: "NONE",
      msg: "", //买家留言
      isMail: "", //是否开启邮箱
      email: "", //邮箱号码
      buyNow: true, //从哪里进来true 立即购买 false 购物车
      invoiceName: "",
      invoiceCode: "",
      isShowPay: false,
      addressInfo: {
        addrId: "",
        name: "",
        mobile: "",
        province: "",
        city: "",
        area: "",
        address: "",
        postcode: "",
        isDefult: false,
      },
      isInvoice: -1,
      userPoints: false, //是否使用积分抵扣
      totalAllPrice: 0.0, //总价格
      totalPostage: null, //需要支付总邮费
      totalPoints: 0, //总积分
      totalPointsPrice: 0, //总抵扣金额
      deductedCouponPrice: 0, //总优惠券抵扣金额
      rmb2Points: 0, //积分抵扣比例
      balance: 0, //账户余额
      freeShipping: null,
      shopList: [],
      couponList: [],
      showCoup: false,
      choosedCouponIndex: -1,
      choosedCouponPrice: 0, // 选中优惠券价值，默认选中最高抵扣
      isFirstChooseCoupon: true,
      vipType: -1,
      payType: 0,
      isClg: false, // 是否拼团
      isSales: false, // 是否限时购
      isIntegral: 0,
      pMallGood: {}, //积分
      subStatus: 0,
      talId: "", //大转盘传过来得中奖id
      isTurntable: false, //大转盘标识
      isPayAward: false,
      isGiftRelate: false,
      typeList: [
        { index: 1, name: "物流分配" },
        { index: 2, name: "线下自提" },
      ],
      typeIndex: 1,
      deliverType: 1, //1物流 2线下自提 3物流+线下
      nearOffline: null, //最近自提地址
      currentCityInfo: null, //当前城市信息
      showAddressInfo: false, //修改自提人信息
      cityName: "",
      offlineAddressInfo: {
        //自提人信息
        name: "",
        mobile: "",
      },
      isFromSelectAddress: false, //是否离开去地址页
      numOperate: false, //判断是否时商品数量变化
      guideData: "", //入群引导数据
      orderType: "", //订单类型
      showCashBack: false, // 满减弹窗
      cashBack: null, // 当前满减信息
      cashBackList: [], // 满减商品活动列表
      isAssociatedForm: false, //判断是否关联表单
      isSubMch: 0, //1是服务商二级商户， 0普通商户
      prodId: "", //所有的订单的prodId
      relData: [], // 商品关联售卖列表
      protocolInfo: null, // 协议
      isCheckAgreement: false, // 是否同意协议
      isInBargain: false, // 判断是否是砍价
      payConf: {},
      coinAmount: 0, // 虚拟币总额
      isCanUseGiftCard: false, // 后台是否开启虚拟支付
      proportion: 0, // 虚拟币兑换率
      totalCoin: 0, // 虚拟币总合
      useCoinPay: false, // 使用虚拟币支付
      allOriginalPrice: 0, // 商品原价
      fromLIve: false, // 从直播跳转过来
      giftCardInfo: {}, //虚拟币商品信息
      ckFrom: global.ckFrom,
      presale: null, // 预售数据
      moneyType: 1, // 预售款项判断
      enableDeduction: 0, // 预售判断是否用折扣
      presaleGoId: '', // 预售定金订单号
      invoiceInfo: null, // 开票信息
      chainInfo: '',
      customPointName: localStorage.getItem("customPointName"),
      goodList: [], // 获取订单商品列表的enableUsedPoints设置
      cashBackReduce: 0, // 满减赠满减价格
      mallOfflineUser: null, // 自提点信息
    };
  },
  computed: {
    // 判断是否显示积分抵抗
    isShowPointsSwitch() {
      // 积分大于0 && 总使用积分金额 && 非拼团 && 非满减赠 && 非预售定金 && 非预售尾款不叠加其他优惠抵扣处理
      let isShowPointsSwitch = this.totalPoints * 1 > 0 && this.totalPointsPrice * 1 > 0 && !this.isClg && !this.cashBack && !this.isInBargain && !(this.presale && (this.moneyType == 2 || (this.moneyType == 3 && this.enableDeduction == 0)));
      if (!this.goodList || (this.goodList && this.goodList.length == 0) || !isShowPointsSwitch) return isShowPointsSwitch;
      this.shopList.forEach(item => {
        item.enableUsedPoints = this.goodList.find(it => it.mgId == item.mgId).enableUsedPoints;
      })
      if (this.shopList.every(item => item.enableUsedPoints)) {
        return isShowPointsSwitch
      }
      // 设置折扣跟积分互斥的商品
      let unableUsePoint = this.shopList.filter(item => !item.enableUsedPoints);
      // 设置折扣跟积分互斥的商品全部(没有折扣) || (链动商品无链动优化) => 可以继续是有积分折扣
      if (unableUsePoint.every(item => ((!item.dignityDis && !item.isFromChain) || (item.isFromChain && item.orderBonus == item.price)))) {
        // 互斥无折扣积分还可以使用
        return isShowPointsSwitch
      } else {
        // 互斥有折扣积分则不能用
        return !isShowPointsSwitch
      }
    },
    // 获取尾款支付日期如下： 3月28日 9:30-3月31日9:30
    getLeaveTime() {
      if (this.presale == null) return
      let leaveStartTime = new Date(this.presale.leaveStartTime.replace(/-/g, "/"));
      let leaveEndTime = new Date(this.presale.leaveEndTime.replace(/-/g, "/"));
      return `${leaveStartTime.getMonth() + 1}月${leaveStartTime.getDate()}日 ${leaveStartTime.getHours() > 9 ? '' + leaveStartTime.getHours() : '0' + leaveStartTime.getHours()}:${leaveStartTime.getMinutes() > 9 ? '' + leaveStartTime.getMinutes() : '0' + leaveStartTime.getMinutes()} - ${leaveEndTime.getMonth() + 1}月${leaveEndTime.getDate()}日 ${leaveEndTime.getHours() > 9 ? '' + leaveEndTime.getHours() : '0' + leaveEndTime.getHours()}:${leaveEndTime.getMinutes() > 9 ? '' + leaveEndTime.getMinutes() : '0' + leaveEndTime.getMinutes()}`
    },
    onlyValuationMethod() {
      let flag = this.shopList.every((item) => item.valuationMethod && item.valuationMethod == 2);
      return flag;
    },
    // 关联售卖文案
    relDataNumText() {
      let courseNum = 0,
        columnNum = 0,
        vipNum = 0;
      let txt = "";
      this.relData.forEach((item) => {
        if ([110, 111, 112].includes(item.prodType)) {
          courseNum++;
        } else if (item.prodType == global.ckFrom.column) {
          columnNum++;
        } else if (item.prodType == global.ckFrom.vip || item.prodType == global.ckFrom.svip) {
          vipNum++;
        }
      });
      if (courseNum > 0) {
        txt += courseNum + "个课程" + (columnNum > 0 || vipNum > 0 ? "/" : "");
      }
      if (columnNum > 0) {
        txt += columnNum + "个专栏" + (vipNum > 0 ? "/" : "");
      }
      if (vipNum > 0) {
        txt += vipNum + "个会员";
      }
      return txt;
    },
    // 获取满减信息的循环
    getCashBackLoop() {
      let loop = 1;
      let useMcb = this.getUseMcbgId;
      let cashBackTotal = this.cashBack.products.reduce((price, item) => {
        return price + item.price * 1 * item.quantity;
      }, 0);
      let quantity = this.cashBack.products.reduce((quantity, item) => {
        return quantity + item.quantity * 1;
      }, 0);
      if (useMcb.ruleType == 2) {
        loop = useMcb.backType == 1 ? Math.floor(cashBackTotal / useMcb.thresholdAmount) : Math.floor(quantity / useMcb.thresholdAmount);
      }
      return loop;
    },
    // 获取符合满减的对应阶梯信息
    getUseMcbgId() {
      if (this.cashBack && this.cashBack.useMcbgId) {
        let useMcb = this.cashBack.contents.filter((item) => item.mcbgId == this.cashBack.useMcbgId);
        useMcb = useMcb.length > 0 ? useMcb[0] : null;
        return useMcb;
      } else {
        return null
      }
    },
    // 商品数量添加的最大值限制
    shopNumberMax() {
      return function (item) {
        let max = this.isInBargain ? item.stock : item && item.isFlashSales ? (item.salesLimt > 0 ? item.salesLimt : item.stock) : item && item.isCollage ? (item.collageLimit > 0 ? item.collageLimit : item.stock) : item && item.limitType != -1 ? item.limitNumber - item.purchasedNum : item.stock;
        return max;
      };
    },
    ...mapState({
      livePrizeInfo: (state) => state.live.prizeInfo,
    }),
  },
  watch: {
    $route(to, from) {
      if (to.path != "/mall/offlineSite/offlineSiteList" && to.path != "/mall/shippingAddress/addressList" && to.path != "/mall/shopSettlement/shopSettlement" && to.path != "/mall/shippingAddress/addressInfo" && to.path != "/mall/mallOrder/orderDetail") {
        this.isFromSelectAddress = false;
        localStorage.removeItem("mod");
        localStorage.removeItem("shopMgId");
        this.offlineAddressInfo = {
          name: "",
          mobile: "",
        };
        this.nearOffline = null;
        this.currentCityInfo = null;
        isGetOrder = 0;
        isCheckAgreement = -1;
      }
    },
    //监听商品满减数据变化，自动计算总价格
    cashBackList: {
      handler(newList, oldList) {
        if (this.cashBack) {
          // 从满足满减条件到不满足，恢复普通商品优惠计算
          this.cashBack = null;
          this.isFirstChooseCoupon = true;
          if (this.couponList && this.couponList.length > 0 && isAutoChooseCoupon) {
            canUseCoupon = [];
            this.isCanUseCoupon(this.couponList, newList).then(() => {
              this.choosedCouponIndex = -1;
              this.initChoosedCouponPrice();
            });
          }
        }
        this.getCashBack(newList[0]);
      },
      deep: true,
    },
    //监听商品数据变化，自动计算总价格
    shopList: {
      handler(newList, oldList) {
        this.getGivenPoints(newList);
        if ((this.couponList && this.couponList.length == 0) || !this.couponList) {
          this.getPayMoney(newList, this.userPoints);
        }
        // 商品数量切换的时候自动切换优惠券和计算价格 预售尾款不参加优惠叠加不计算\定金优惠券
        if (this.presale && (this.moneyType == 3 && this.enableDeduction == 0) || (this.moneyType == 2)) return
        if (this.couponList && this.couponList.length > 0 && isAutoChooseCoupon) {
          canUseCoupon = [];
          this.isCanUseCoupon(this.couponList, newList).then(() => {
            this.choosedCouponIndex = -1;
            this.initChoosedCouponPrice();
          });
        }
      },
      deep: true,
    },
    userPoints: {
      handler(newList, oldList) {
        this.getPayMoney(this.shopList, newList);
      },
    },
    showCoup(val) {
      if (val) {
        //开启弹窗时记录当前滚动距离
        curScollTop = document.documentElement.scrollTop || document.body.scrollTop;
        document.querySelector("body").classList.add("open-disabled-scroll");
      } else {
        document.querySelector("body").classList.remove("open-disabled-scroll");
        //关闭弹窗，恢复滚动位置
        window.scrollTo(0, curScollTop);
      }
    },
    couponList(val) {
      if (val && val.length > 0) {
        // 初始化优惠券价格
        if (this.isFirstChooseCoupon) {
          this.initChoosedCouponPrice();
        }
      }
    },
  },
  methods: {
    // 关闭开票弹窗
    clickCloseModal() {
      this.showInvoice = false;
    },
    //显示发票弹窗
    clickShowInvoice() {
      this.showInvoice = true;
      this.$refs.invoiceModal.public_initData(this.invoiceInfo);
    },
    // 获取开票信息
    getInvoice(data) {
      this.showInvoice = false;
      this.invoiceInfo = data;
    },
    //计算支付虚拟币总额
    _calcCoin() {
      if (this.isCanUseGiftCard) {
        let postageCoin = Math.ceil(Number(this.totalPostage) * this.proportion);
        let originalPrice = this.shopList.reduce((price, item) => {
          return price + item.price * item.quantity;
        }, 0);
        // 判读是否有邮费
        let hasPostage = !((this.freeShipping != null && (this.totalPostage == null || this.totalPostage == 0)) || this.typeIndex == 2 || this.deliverType == 2);
        if (this.giftCardInfo.unableMarketing) {
          //不叠加使用
          let priceCoin = 0;
          if (hasPostage) {
            originalPrice = originalPrice * 1 + this.totalPostage;
          }
          priceCoin = this.shopList.reduce((price, item) => {
            return price + Math.ceil(item.price * this.proportion) * item.quantity;
          }, 0);
          this.allOriginalPrice = originalPrice;
          this.totalCoin = hasPostage ? priceCoin + postageCoin : priceCoin;
        } else {
          //叠加(优惠完以后按照原价比例折算);
          // this.allOriginalPrice = this.totalAllPrice;
          // this.totalCoin = this.shopList.reduce((price, item) => {
          //   return price + Math.ceil((item.price * item.quantity) / originalPrice * (this.totalAllPrice - this.totalPostage) * this.proportion);
          // }, 0);
          if (!this._productPriceArrForSingle || (this._productPriceArrForSingle && this._productPriceArrForSingle.length == 0)) return
          this.totalCoin = this.shopList.reduce((price, item, index) => {
            return price + Math.ceil(this._productPriceArrForSingle[index].toFixed(2) * this.proportion) * item.quantity;
          }, 0)
          // console.log("this.totalPostage", this.totalPostage, this._productPriceArrForSingle)
          this.totalCoin = hasPostage ? this.totalCoin + postageCoin : this.totalCoin;
          this.allOriginalPrice = this.totalCoin / this.proportion;
        }
      }
    },
    clickProtocol(item) {
      this.$routerGo(this, "push", { path: `/homePage/agent/protocolInfo`, query: { protocolId: item.protocolId } });
    },
    public_initFromDetailData() {
      this.fromLIve = true;
      this.initData();
      this.isFromSelectAddress = false;
      this.offlineAddressInfo = {
        name: "",
        mobile: "",
      };
      this.nearOffline = null;
      this.currentCityInfo = null;
      isGetOrder = 0;
    },
    // 获取商品是否符合满减活动
    getCashBack(currentCashBack) {
      return new Promise(resolve => {
        if (!currentCashBack || !currentCashBack.products) {
          this.cashBack = null;
          resolve()
          return
        }
        let cashBackTotal = currentCashBack.products.reduce((price, item) => {
          return price + item.price * 1 * item.quantity;
        }, 0);
        let loop = 0;
        let quantity = currentCashBack.products.reduce((quantity, item) => {
          return quantity + item.quantity * 1;
        }, 0);
        // 阶级满减
        if (currentCashBack.ruleType == 1) {
          for (let item of currentCashBack.contents) {
            if ((cashBackTotal >= item.thresholdAmount && item.backType == 1) || (quantity >= item.thresholdAmount && item.backType == 2)) {
              this.cashBack = {
                useMcbgId: item.mcbgId,
              };
            }
          }
          if (this.cashBack && this.cashBack.useMcbgId) {
            this.cashBack.title = currentCashBack.title;
            this.cashBack.contents = currentCashBack.contents;
            this.cashBack.mcbId = currentCashBack.mcbId;
            this.cashBack.ruleType = currentCashBack.ruleType;
            this.cashBack.products = currentCashBack.products;
            let useMcb = currentCashBack.contents.filter((item) => {
              return item.mcbgId == this.cashBack.useMcbgId;
            })[0];
            if (useMcb.isDiscount != 1) {
              this.cashBack.reduce = 0;
              resolve()
              return
            }
            if (useMcb.discountType == 1) {
              this.cashBack.reduce = utilJs.toMyFixed2(useMcb.backAmount);
            } else {
              this.cashBack.reduce = utilJs.toMyFixed2(cashBackTotal - ((useMcb.backDiscount * 1) / 100) * cashBackTotal);
            }
          }
          // 循环满减 (只有金额累加满减无打折满减)
        } else {
          if ((cashBackTotal >= currentCashBack.contents[0].thresholdAmount && currentCashBack.contents[0].backType == 1) || (quantity >= currentCashBack.contents[0].thresholdAmount && currentCashBack.contents[0].backType == 2)) {
            this.cashBack = {
              title: currentCashBack.title,
              useMcbgId: currentCashBack.contents[0].mcbgId,
              contents: currentCashBack.contents,
              mcbId: currentCashBack.mcbId,
              ruleType: currentCashBack.ruleType,
              products: currentCashBack.products,
            };
            let useMcb1 = currentCashBack.contents[0];
            this.useMcbId = useMcb1.mcbgId;
            loop = useMcb1.backType == 1 ? Math.floor(cashBackTotal / useMcb1.thresholdAmount) : Math.floor(quantity / useMcb1.thresholdAmount);
            if (useMcb1.isDiscount != 1) {
              this.cashBack.reduce = 0;
              resolve()
              return
            }
            this.cashBack.reduce = utilJs.toMyFixed2(useMcb1.backAmount * loop);
          }
        }
        if (this.cashBack) {
          this.choosedCouponIndex = -1;
          this.choosedCouponPrice = 0;
          this.cashBackProducts = this.cashBackList[0].products;
          this.getPayMoney(this.cashBackProducts, this.userPoints);
        }
        resolve()
      })
    },
    //计算vip或者服务商折扣
    discountServer(item, vipType) {
      let discountObj = {
        2: "VIP" + (item.vipDiscount == 0 ? "免费 " : parseFloat((item.vipDiscount / 10).toFixed(3)) + "折"),
        4: "SVIP" + (item.svipDiscount == 0 ? "免费 " : parseFloat((item.svipDiscount / 10).toFixed(3)) + "折")
      };
      if (!discountObj[vipType] && item.commonProdInfo) {
        return item.commonProdInfo.agentName + item.commonProdInfo.agentDiscount == 0 ? "免费 " : parseFloat((item.commonProdInfo.agentDiscount / 10).toFixed(3)) + "折"
      }
      return discountObj[vipType];
    },
    // 超出商品可购买的最大限额
    outMaxNum(limitNumber, purchasedNum, inputNumber) {
      if (limitNumber <= purchasedNum) {
        this.$showCjToast({
          text: "您已购买过该商品，当前不能购买更多了",
          type: "warn",
        });
      } else if (limitNumber <= purchasedNum + inputNumber) {
        this.$showCjToast({
          text: "当前不能购买更多了",
          type: "warn",
        });
      }
    },
    changeType(index) {
      this.typeIndex = index;
      if (this.typeIndex == 2) {
        if (!this.currentCityInfo) {
          this.getOffline();
        }
      }
      //tab切换邮费变化
      this.getPayMoney(this.shopList, this.userPoints);
    },
    showIntegralTip() {
      this.$cjConfirm({
        title: '提示',
        message: `您的${this.customPointName}不足，无法兑换`,
        confirmButtonText: `去赚${this.customPointName}`,
        onConfirm:() => {
          this.onConfirm();
        }
      })
    },
    onConfirm() {
      this.$routerGo(this, "replace", {
        path: "/member/myIntegral/integralIndex",
      });
    },
    initData() {
      let shopList = sessionStorage.getItem("shopBuyInfo") ? JSON.parse(sessionStorage.getItem("shopBuyInfo")) : [];
      this.typeIndex = shopList && shopList[0] && shopList[0].isMallExpressDeliver == -1 && shopList[0].isMallOfflineDeliver == 1 ? 2 : 1;
      this.invoiceType = "NONE";
      this.invoiceName = "";
      this.invoiceCode = "";
      this.email = "";
      this.msg = "";
      this.userPoints = false; //是否使用积分抵扣
      this.addressInfo = {
        addrId: "",
        name: "",
        mobile: "",
        province: "",
        city: "",
        area: "",
        address: "",
        postcode: "",
        isDefult: false,
      };
      this.mallOfflineUser = null;
      this.offlineAddressInfo = {
        name: "",
        mobile: "",
      };
      this.cashBackReduce = 0;
      shopAllList = [];
      localStorage.removeItem("mod");
      localStorage.removeItem("shopMgId");
    },
    // 判断全部商品满减券/指定商品满减优惠券
    isCanUseCoupon(couponList, shopList) {
      return new Promise((resolve, reject) => {
        // 过滤全部商品满减券未达满减
        canUseCoupon = couponList.filter((cItem, index) => cItem.amount * 1 <= shopVipTotlaPrice || cItem.amount * 1 == 0 || cItem.subType == 1);
        // 过滤指定商品满减券未达满减
        let redeemIdMap = {};
        let redeemIdArr = [];
        for (let i = 0; i < canUseCoupon.length; i++) {
          let item = canUseCoupon[i];
          if (item.arrRedeemId && item.arrRedeemId.length > 0) {
            redeemIdArr.push(item.eRcdId);
            redeemIdMap[item.eRcdId] = {
              items: null,
              coupon: item,
            };
          }
        }
        let redeemIdList = Object.keys(redeemIdMap).map((key) => redeemIdMap[key]);
        for (let i = 0; i < redeemIdList.length; i++) {
          let list = shopList.filter((shopItem) => redeemIdMap[redeemIdArr[i]].coupon.arrRedeemId.indexOf(shopItem.mgId) > -1);
          redeemIdMap[redeemIdArr[i]].items = list;
        }
        let couponTem = canUseCoupon;
        for (let i = 0; i < canUseCoupon.length; i++) {
          let item = canUseCoupon[i];
          let totalPrice = 0;
          if (item.arrRedeemId && item.arrRedeemId.length > 0) {
            let items = redeemIdMap[item.eRcdId].items;
            totalPrice = items.reduce((price, pItem) => {
              return price + pItem.totalPrice;
            }, 0);
            if (item.amount * 1 > totalPrice * 1) {
              couponTem = couponTem.filter((cItem) => cItem.eRcdId != item.eRcdId);
            }
          }
        }
        canUseCoupon = [];
        canUseCoupon = couponTem;
        isAutoChooseCoupon = false;
        resolve();
      });
    },
    // 初始化优惠券选中价格
    initChoosedCouponPrice() {
      return new Promise((resolve, reject) => {
        // 限时购/拼团/大转盘/支付有礼/砍价不参与优惠券购买
        if (!(this.companyAuth.enableRedeemCode == 1 && this.isIntegral == 0 && (this.isTurntable == false || this.isPayAward == false || this.isGiftRelate == false) && this.isInBargain == false)) {
          return;
        }
        if (canUseCoupon && canUseCoupon.length == 0) {
          this.choosedCouponPrice = 0;
          this.choosedCouponIndex = -1;
          return;
        }
        // 获取比(折后价)抵扣金额高的优惠券, 存在这种优惠金额就用这种优惠的最低金额优惠券, 不存在再使用优惠金额最高的券
        let canUseRcdId = canUseCoupon[0].eRcdId;
        let matchMaxCouponList = canUseCoupon.filter((item) => item.price * 1 > shopVipTotlaPrice && item.type != 5);
        let matchMinCouponList = canUseCoupon.filter((item) => item.price * 1 <= shopVipTotlaPrice || item.type == 5);
        if (!matchMaxCouponList || (matchMaxCouponList && matchMaxCouponList.length == 0)) {
          let max = 0;
          if (matchMinCouponList[0].type == 5) {
            if ((1 - Number(matchMinCouponList[0].price) / 10) * shopVipTotlaPrice > matchMinCouponList[0].totalAmount && !!matchMinCouponList[0].enableTotalAmount) {
              max = matchMinCouponList[0].totalAmount
            } else {
              max = (1 - Number(matchMinCouponList[0].price) / 10) * shopVipTotlaPrice;
            }
          } else {
            max = matchMinCouponList[0].price * 1;
          }
          for (let i = 0; i < matchMinCouponList.length; i++) {
            if (matchMinCouponList[i].price * 1 > max && matchMinCouponList[i].type != 5) {
              max = matchMinCouponList[i].price * 1;
              canUseRcdId = matchMinCouponList[i].eRcdId;
            } else if (matchMinCouponList[i].type == 5) {
              let discontMax = 0;
              if ((1 - Number(matchMinCouponList[i].price) / 10) * shopVipTotlaPrice > matchMinCouponList[i].totalAmount && !!matchMinCouponList[i].enableTotalAmount) {
                discontMax = matchMinCouponList[0].totalAmount
              } else {
                discontMax = (1 - Number(matchMinCouponList[i].price) / 10) * shopVipTotlaPrice;
              }
              if (discontMax > max) {
                max = discontMax;
                canUseRcdId = matchMinCouponList[i].eRcdId;
              }
            }
          }
          this.choosedCouponPrice = max;
        } else {
          let min = matchMaxCouponList[0].price * 1;
          canUseRcdId = matchMaxCouponList[0].eRcdId;
          for (let i = 0; i < matchMaxCouponList.length; i++) {
            if (matchMaxCouponList[i].price * 1 < min) {
              min = matchMaxCouponList[i].price * 1;
              canUseRcdId = matchMaxCouponList[i].eRcdId;
            }
          }
          this.choosedCouponPrice = min;
        }
        for (let a = 0; a < this.couponList.length; a++) {
          let item = this.couponList[a];
          if (item.eRcdId == canUseRcdId) {
            this.choosedCouponIndex = a;
            break;
          }
        }
        // 商品折后价大于优惠券价格或者无门槛或者折后价为0，不使用优惠券
        if (this.choosedCouponIndex == -1 || (shopVipTotlaPrice < this.couponList[this.choosedCouponIndex].amount * 1 && this.couponList[this.choosedCouponIndex].subType != 1) || shopVipTotlaPrice * 1 == 0) {
          this.choosedCouponPrice = 0;
          this.choosedCouponIndex = -1;
        }
        this.isFirstChooseCoupon = false;
        this.getPayMoney(this.shopList, this.userPoints);
        resolve();
      });
    },
    // 计算赠送的积分
    getGivenPoints(shopList) {
      givenPoints = shopList.reduce((Points, item) => {
        return Points + item.givenPoints * item.quantity;
      }, 0);
    },
    /**
     *  单个商品优惠券抵扣额度 = 0
        if 使用通用优惠券
          单个商品优惠券抵扣额度 = (商品原价 * 商品数量)/所有商品价格 * 优惠券原始金额
          单个商品优惠券抵扣额度 = 单个商品优惠券抵扣额度 > 商品原价 * 商品数量 ？ 商品原价 * 商品数量 ： 单个商品优惠券抵扣额度
        else 使用指定该商品抵扣券
            单个商品优惠券抵扣额度 = 优惠券原始金额

        用户剩余积分 = 用户积分
        商品可抵扣金额 = 商品的原可抵扣额度 * 商品数量
        商品可抵扣金额 = 商品可抵扣金额 > 商品原价 * vip折扣 * 商品数量 - 单个商品优惠券抵扣额度 ？  商品原价 * vip折扣 * 商品数量 - 单个商品优惠券抵扣额度 ： 商品可抵扣金额
        单个商品可抵扣积分 = 商品可抵扣金额 * 积分转化比例
        单个商品可抵扣积分 = 单个商品可抵扣积分 > 用户剩余积分 ？ 用户剩余积分 ： 单个商品可抵扣积分
        用户剩余积分 = 用户剩余积分 - 单个商品可抵扣积分

        每个商品的最终价格 = 商品原价 * 商品折扣价 - 单个商品优惠券抵扣额度 - 单个商品可抵扣积分/积分转化比例
     */
    getPayMoney(shopList, isUsePonits) {
      if (shopList && shopList.length == 0) {
        return;
      }
      isUsePonits = this.cashBack == null ? isUsePonits : false;
      let useVipCouponAllPrice = 0;
      if (this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && this.couponList[this.choosedCouponIndex].redeemType == 24 && this.couponList[this.choosedCouponIndex].redeemSubType == 1) {
        let useShopInfoArr = shopList.filter((item) => {
          return this.couponList[this.choosedCouponIndex].arrRedeemId.indexOf(item.mgId) > -1;
        });
        //计算商品的折后价 (区分链动跟身份折扣)
        if (useShopInfoArr.find(item => item.isFromChain == true && item.orderBonus * 1 > 0)) {
          useVipCouponAllPrice = useShopInfoArr.reduce((cPrice, item) => {
            return utilJs.toMyFixed2(cPrice + item.orderBonus * item.quantity);
          }, 0);
        } else {
          useVipCouponAllPrice = useShopInfoArr.reduce((cPrice, item) => {
            return cPrice + item.price * item.quantity * item.dignityDiscount;
          }, 0); //指定商品总金额
        }
        if (useVipCouponAllPrice * 1 == 0) {
          this.$showCjToast({
            text: "购买金额为0，无法使用优惠券",
            type: "warn",
          });
          this.clickCoupon(this.choosedCouponIndex);
          return;
        }
        //判断指定商品优惠券满减是否可用  指定商品总金额 < 满减金额 ---不可使用优惠券
        if (utilJs.toMyFixed2(useVipCouponAllPrice) < this.couponList[this.choosedCouponIndex].amount * 1) {
          this.$showCjToast({
            text: "购买金额未达到要求，不可使用满减券",
            type: "warn",
          });
          this.clickCoupon(this.choosedCouponIndex);
        }
      } else if (this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && (this.couponList[this.choosedCouponIndex].redeemType == 26 || (this.couponList[this.choosedCouponIndex].redeemType == 24 && this.couponList[this.choosedCouponIndex].redeemSubType != 1))) {
        if (shopVipTotlaPrice * 1 == 0) {
          this.$showCjToast({
            text: "购买金额为0，无法使用优惠券",
            type: "warn",
          });
          this.clickCoupon(this.choosedCouponIndex);
          return;
        }
        //判断全店通用优惠券是否可用 所有商品总价 < 满减金额 ---不可使用优惠券
        if (utilJs.toMyFixed2(shopVipTotlaPrice) < this.couponList[this.choosedCouponIndex].amount * 1 && this.couponList[this.choosedCouponIndex].subType != 1) {
          this.$showCjToast({
            text: "购买金额未达到要求，不可使用满减券",
            type: "warn",
          });
          this.clickCoupon(this.choosedCouponIndex);
        }
      }
      let discountType = 1; //1: 折扣券按打折方式 2：折扣券使用最多可优惠金额，按比例分配优惠
      let totalPoints = 0; //总使用积分
      let totalPointsPrice = 0; //总使用积分金额
      let totalCouponPrice = 0;
      let totalAllPrice = 0;
      let berforCouponPirce = 0; //前几个优惠券金额总和
      let subUserPoints = curUserPoints; //用户剩余积分
      //使用折扣券时，先用打折的方式计算，如果优惠金额超过最多可优惠金额，则换成使用最多可优惠金额，按比例分配优惠
      for (let j = 0; j < 2; j++) {
        totalPoints = 0; //总使用积分
        totalPointsPrice = 0; //总使用积分金额
        totalCouponPrice = 0;
        totalAllPrice = 0;
        berforCouponPirce = 0; //前几个优惠券金额总和
        subUserPoints = curUserPoints; //用户剩余积分
        for (let i = 0; i < shopList.length; i++) {
          let item = shopList[i];
          let itemCouponMoney = 0; //单个商品优惠券抵扣额度
          //使用通用优惠券
          if (this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && (this.couponList[this.choosedCouponIndex].redeemType == 26 || (this.couponList[this.choosedCouponIndex].redeemType == 24 && this.couponList[this.choosedCouponIndex].redeemSubType != 1)) && this.cashBack == null) {
            if (i == shopList.length - 1) {
              if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 1) {
                let discontMax = 0;
                // if ((1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice > this.couponList[this.choosedCouponIndex].totalAmount && !!this.couponList[this.choosedCouponIndex].enableTotalAmount) {
                //   discontMax = this.couponList[this.choosedCouponIndex].totalAmount
                // } else {
                  discontMax = (1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice;
                // }
                itemCouponMoney = discontMax;
              } else if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 2) {
                itemCouponMoney = this.getPointTwoNum((this.couponList[this.choosedCouponIndex].totalAmount - berforCouponPirce).toFixed(4));
              } else {
                itemCouponMoney = this.getPointTwoNum((this.couponList[this.choosedCouponIndex].price - berforCouponPirce).toFixed(4));
              }
              itemCouponMoney = itemCouponMoney > item.totalPrice ? item.totalPrice : utilJs.toMyFixed2(itemCouponMoney);
            } else {
              if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 1) {
                let discontMax = 0;
                // if ((1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice > this.couponList[this.choosedCouponIndex].totalAmount && !!this.couponList[this.choosedCouponIndex].enableTotalAmount) {
                //   discontMax = this.couponList[this.choosedCouponIndex].totalAmount
                // } else {
                  discontMax = (1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice;
                // }
                itemCouponMoney = discontMax;
              } else if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 2) {
                itemCouponMoney = (item.totalPrice / shopVipTotlaPrice) * this.couponList[this.choosedCouponIndex].totalAmount;
              } else {
                itemCouponMoney = (item.totalPrice / shopVipTotlaPrice) * this.couponList[this.choosedCouponIndex].price;
              }
              itemCouponMoney = itemCouponMoney > item.totalPrice ? item.totalPrice : utilJs.toMyFixed2(itemCouponMoney);
              berforCouponPirce += itemCouponMoney * 1;
            }
          } else if (this.cashBack == null && this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && this.couponList[this.choosedCouponIndex].redeemType == 24 && this.couponList[this.choosedCouponIndex].redeemSubType == 1 && this.couponList[this.choosedCouponIndex].arrRedeemId.indexOf(item.mgId) > -1) {
            //使用指定商品
            if (i == shopList.length - 1) {
              if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 1) {
                let discontMax = 0;
                // if ((1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice > this.couponList[this.choosedCouponIndex].totalAmount && !!this.couponList[this.choosedCouponIndex].enableTotalAmount) {
                //   discontMax = this.couponList[this.choosedCouponIndex].totalAmount
                // } else {
                  discontMax = (1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice;
                // }
                itemCouponMoney = discontMax;
              } else if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 2) {
                itemCouponMoney = this.getPointTwoNum((this.couponList[this.choosedCouponIndex].totalAmount - berforCouponPirce).toFixed(4));
              } else {
                itemCouponMoney = this.getPointTwoNum((this.couponList[this.choosedCouponIndex].price - berforCouponPirce).toFixed(4));
              }
              itemCouponMoney = itemCouponMoney > item.totalPrice ? item.totalPrice : itemCouponMoney;
            } else {
              if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 1) {
                let discontMax = 0;
                if ((1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice > this.couponList[this.choosedCouponIndex].totalAmount && !!this.couponList[this.choosedCouponIndex].enableTotalAmount) {
                  discontMax = this.couponList[this.choosedCouponIndex].totalAmount
                } else {
                  discontMax = (1 - Number(this.couponList[this.choosedCouponIndex].price) / 10) * item.totalPrice;
                }
                itemCouponMoney = discontMax;
              } else if (this.couponList[this.choosedCouponIndex].type == 5 && discountType == 2) {
                itemCouponMoney = (item.totalPrice / useVipCouponAllPrice) * this.couponList[this.choosedCouponIndex].totalAmount;
              } else {
                itemCouponMoney = (item.totalPrice / useVipCouponAllPrice) * this.couponList[this.choosedCouponIndex].price;
              }
              itemCouponMoney = itemCouponMoney > item.totalPrice ? item.totalPrice : utilJs.toMyFixed2(itemCouponMoney);
              berforCouponPirce += itemCouponMoney * 1;
            }
          }
          totalCouponPrice += itemCouponMoney * 1;
          if (itemCouponMoney > 0 && this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && this.couponList[this.choosedCouponIndex].type == 5 && !!this.couponList[this.choosedCouponIndex].enableTotalAmount) {
            if (totalCouponPrice > this.couponList[this.choosedCouponIndex].totalAmount) {
              discountType = 2;
              break
            }
          }
          let itemPointsDeductMoney = item.pointsDeduct * item.quantity; //商品可抵扣金额
          let itemCoupontEndPrice = item.totalPrice - itemCouponMoney; //商品使用优惠券后的价格
          itemPointsDeductMoney = itemPointsDeductMoney > itemCoupontEndPrice ? itemCoupontEndPrice : itemPointsDeductMoney;
          let itemPointsDeduct = itemPointsDeductMoney * this.rmb2Points; //商品可抵扣积分
          itemPointsDeduct = itemPointsDeduct > subUserPoints ? subUserPoints : itemPointsDeduct;
          itemPointsDeductMoney = this.getPointTwoNum((itemPointsDeduct / this.rmb2Points).toFixed(4)); //舍去小数点两位后的数值
          subUserPoints = subUserPoints - itemPointsDeduct;
          let itemTotalPrice = isUsePonits ? itemCoupontEndPrice - itemPointsDeductMoney : itemCoupontEndPrice; //单个商品总价
          item.amount = itemTotalPrice * 1 < 0 ? 0 : itemTotalPrice; //单个商品支付总金额
          //虚拟币因为要计算使用优惠券以后单种商品，单个的价格，推入数组
          if (!isNaN(itemTotalPrice)) {
            this._productPriceArrForSingle[i] = itemTotalPrice / item.quantity;
          }
          item.deductedPoints = itemPointsDeduct; //单个商品可抵扣积分
          item.deductedMoney = itemPointsDeductMoney; //单个商品可抵扣金额
          totalPoints += itemPointsDeduct;
          totalPointsPrice += itemPointsDeductMoney;
          totalAllPrice += itemTotalPrice;
          //虚拟币的计算
        }
        if (discountType == 1) {
          break;
        }
      }
      this.totalPoints = Math.ceil((totalPoints * 1).toFixed(4)); //保留4位有效数字是为了防止出现0.0000000001情况
      this.totalPointsPrice = this.getPointTwoNum((totalPointsPrice * 1).toFixed(4));
      this.totalAllPrice = utilJs.toMyFixed2(totalAllPrice);
      this.deductedCouponPrice = utilJs.toMyFixed2(totalCouponPrice);
      if (this.couponList && this.couponList.length > 0 && this.choosedCouponIndex != -1 && this.couponList[this.choosedCouponIndex].type == 5) {
        this.choosedCouponPrice = this.deductedCouponPrice;
      }
      // 满减活动处理
      if (this.cashBack) {
        if (utilJs.toMyFixed2(this.totalAllPrice * 1 - this.cashBack.reduce) <= 0) {
          this.cashBackReduce = this.cashBack.reduce > this.totalAllPrice ? this.totalAllPrice : this.cashBack.reduce;
          if ((this.freeShipping != null && (this.totalPostage == null || this.totalPostage == 0)) || this.typeIndex == 2 || this.deliverType == 2) {
            this.totalAllPrice = 0;
          } else {
            this.totalAllPrice = utilJs.toMyFixed2(this.totalPostage);
          }
        } else {
          this.cashBackReduce = this.cashBack.reduce;
          if ((this.freeShipping != null && (this.totalPostage == null || this.totalPostage == 0)) || this.typeIndex == 2 || this.deliverType == 2) {
            this.totalAllPrice = utilJs.toMyFixed2(totalAllPrice * 1 - this.cashBack.reduce);
          } else {
            this.totalAllPrice = utilJs.toMyFixed2(totalAllPrice * 1 - this.cashBack.reduce + this.totalPostage);
          }
        }
      } else {
        //判断是否包邮(达到包邮的价格/邮费为0/商品自提)
        if ((this.freeShipping != null && (this.totalPostage == null || this.totalPostage == 0)) || this.typeIndex == 2 || this.deliverType == 2) {
          this.totalAllPrice = utilJs.toMyFixed2(this.totalAllPrice);
        } else {
          this.totalAllPrice = this.presale && this.moneyType == 2 ? utilJs.toMyFixed2(this.totalAllPrice * 1) : utilJs.toMyFixed2(this.totalAllPrice * 1 + this.totalPostage);
        }
      }

      // if (this.isCanUseGiftCard) {
      //   let originalPrice = this.shopList.reduce((price, item) => {
      //     return price + item.price * item.quantity;
      //   }, 0);
      //   let postageCoin = 0,
      //     priceCoin = 0;
      //   priceCoin = this.shopList.reduce((price, item) => {
      //     return price + Math.ceil(item.price * this.proportion) * item.quantity;
      //   }, 0);
      //   if (!((this.freeShipping != null && (this.totalPostage == null || this.totalPostage == 0)) || this.typeIndex == 2 || this.deliverType == 2)) {
      //     originalPrice = originalPrice * 1 + this.totalPostage;
      //     postageCoin = Math.ceil(Number(this.totalPostage) * this.proportion);
      //   }
      //   this.allOriginalPrice = originalPrice;
      //   this.totalCoin = priceCoin + postageCoin;
      // }
      // 每次计算价格过滤不符合条件的满减优惠券
      if (this.isFirstChooseCoupon && this.couponList && this.couponList.length > 0) {
        this.isCanUseCoupon(this.couponList, this.shopList);
      }
      // 虚拟币总额换算
      this._calcCoin();
    },
    //将当前数字去掉小数点后两位之后的值
    getPointTwoNum(curNum) {
      curNum = curNum + "";
      var re = /([0-9]+\.[0-9]{2})[0-9]*/;
      return curNum.replace(re, "$1") * 1;
    },
    clickShowCoupon() {
      if (this.couponList.length > 0) {
        this.showCoup = true;
      }
    },
    closeCoupon() {
      this.showCoup = false;
    },
    clickCoupon(index) {
      if (this.choosedCouponIndex == -1 && this.totalAllPrice == 0) {
        this.$showCjToast({
          text: "价格为0不可使用优惠券",
          type: "warn",
        });
        return;
      }
      if (this.choosedCouponIndex == index) {
        this.choosedCouponIndex = -1;
        this.choosedCouponPrice = 0;
      } else {
        this.choosedCouponIndex = index;
        this.choosedCouponPrice = this.couponList[index].price * 1;
      }
      this.getPayMoney(this.shopList, this.userPoints);
    },
    changeAddressInfo(type) {
      if (type == 0) {
        this.showAddressInfo = false;
      }
      if (type == 1) {
        this.offlineAddressInfo = {
          name: "",
          mobile: "",
        };
        if (!utilJs.isPhoneNumber(this.$refs.mobile.value)) {
          this.$showCjToast({
            text: "请填写正确的手机号",
            type: "warn",
          });
          this.offlineAddressInfo.name = this.$refs.name.value;
        } else {
          this.showAddressInfo = false;
          this.offlineAddressInfo.name = this.$refs.name.value;
          this.offlineAddressInfo.mobile = this.$refs.mobile.value;
        }
      }
    },
    showInfo() {
      this.showAddressInfo = true;
    },
    goOfflineList() {
      let pathQuery = {
        cityId: this.currentCityInfo && this.currentCityInfo.cityId ? this.currentCityInfo.cityId : "",
        userLat: this.currentCityInfo && this.currentCityInfo.userLat ? this.currentCityInfo.userLat : "",
        userLng: this.currentCityInfo && this.currentCityInfo.userLng ? this.currentCityInfo.userLng : "",
        isMallExpressDeliver: this.deliverType == 3 ? 1 : -1,
        goodType: this.isIntegral == 1 ? 2 : 1,
      };
      this.isFromSelectAddress = false;
      if (this.fromPage == "SHOP") {
        this.$routerGo(this, "push", {
          path: "/mall/offlineSite/offlineSiteList",
          query: pathQuery,
        });
        return;
      }
      this.$emit("goOfflineList", pathQuery);
    },
    //获取自提点信息
    getNearestOffline() {
      let NearestOffline = `${global.apiurl}goods/getNearestOffline`;
      let data = {
        userLat: this.currentCityInfo && this.currentCityInfo.userLat ? this.currentCityInfo.userLat : "",
        userLng: this.currentCityInfo && this.currentCityInfo.userLng ? this.currentCityInfo.userLng : "",
        mgId: JSON.parse(localStorage.getItem("shopMgId")),
        goodType: this.isIntegral == 1 ? 2 : 1,
      };
      //进入页面马上返回上一级页面，可能mgId会传空导致接口报错
      if (JSON.parse(localStorage.getItem("shopMgId")) == null || JSON.parse(localStorage.getItem("shopMgId")) == undefined) {
        return;
      }
      utilJs.postMethod(NearestOffline, data, (res) => {
        if (this.currentCityInfo) this.currentCityInfo.cityId = res.cityId;
        this.nearOffline = res && res.site ? res.site : null;
        if (this.nearOffline) {
          localStorage.setItem("mod", JSON.stringify(this.nearOffline));
          this.setUsersOffline(this.nearOffline.modId)
        }
      });
    },
    // 缓存用户自提点
    setUsersOffline(modId) {
      let data = {
        modId: modId,
        mgId: JSON.parse(localStorage.getItem('shopMgId'))
      }
      utilJs.postMethod(`${global.apiurl}goods/setUsersOffline`, data, (res) => {
        console.log(res);
      })
    },
    //获取自提点
    getOffline() {
      // 有无开启定位进入自提点选择返回地址
      if (JSON.parse(localStorage.getItem("mod"))) {
        this.nearOffline = JSON.parse(localStorage.getItem("mod"));
        if (this.currentCityInfo) {
          this.currentCityInfo.cityId = this.nearOffline.cityId;
        } else {
          // this.currentCityInfo = {
          //   userLat: "",
          //   userLng: "",
          //   cityId: this.nearOffline.cityId,
          // };
          this.getNearestOffline();
        }
      } else {
        //定位开启获取当前城市最近自提点
        wxUtilJs.getLocation().then(
          (res) => {
            this.currentCityInfo = {
              userLat: res.latitude,
              userLng: res.longitude,
            };
            //获取到城市信息则继续获取该城市离自己最近的自提点
            if (this.currentCityInfo && this.currentCityInfo.userLat != "" && this.currentCityInfo.userLng != "") {
              this.getNearestOffline();
            }
          },
          (failRes) => {
            console.log("获取经纬度失败");
            this.getNearestOffline();
          }
        );
      }
    },
    //获取订单页信息
    async getOrderInfo(goId) {
      console.log("typeIndex:" + this.typeIndex);
      let cbProdects = this.shopList.filter((item) => {
        return item.mcbId != null;
      });
      if (cbProdects.length > 0) this.$set(this.cashBackList[0], "products", cbProdects);
      //优惠券需要根据商品ID数组获取
      let arrGodId = []; // 需要邮费商品id
      let goodList = []; // 包邮商品
      let freeShipping = null; // 商品达到包邮价
      let fromWhere = true;
      let shopList = this.shopList;
      let totalPrice = 0;
      let vipType = this.vipType;
      await this.getCashBack(this.cashBackList[0]);
      for (let key of shopList) {
        key.price = key.defaultPrice;
        if (
          (vipType == 2 && key.vipDiscount != null && ((key.vipDiscountType == 1 && key.vipDiscount < 100 && key.vipDiscount >= 0) || (key.vipDiscountType == 2 && key.vipDiscount != key.defaultPrice))) ||
          (vipType == 4 && key.svipDiscount != null && ((key.vipDiscountType == 1 && key.svipDiscount < 100 && key.svipDiscount >= 0) || (key.vipDiscountType == 2 && key.svipDiscount != key.defaultPrice))) ||
          ((vipType == 3 || vipType > 4) && key.commonProdInfo && ((key.vipDiscountType == 1 && key.commonProdInfo.agentDiscount < 100) || (key.vipDiscountType == 2 && key.commonProdInfo.agentDiscount != key.defaultPrice)))
        ) {
          key.dignityDis = true;
        } else {
          key.dignityDis = false;
        }
        if (!this.isMail) {
          // 判断商品是否开启邮箱
          this.isMail = key.isMail == 1;
        }
        fromWhere = !key.mcId;
        key.dignityDiscount = 1;
        if (!key.isCollage && !key.isFlashSales && !(this.cashBack && this.getUseMcbgId) && !this.isInBargain && !this.presale && !key.isFromChain && vipType != 1) {
          if (key.vipDiscountType == 1) {
            if (vipType == 2) {
              key.dignityDiscount = (key.vipDiscount = key.vipDiscount || key.vipDiscount === 0 ? key.vipDiscount : 100) / 100;
            } else if (vipType == 4) {
              key.dignityDiscount = (key.svipDiscount = key.svipDiscount || key.svipDiscount === 0 ? key.svipDiscount : 100) / 100;
            } else {
              key.dignityDiscount = (key.commonProdInfo && key.commonProdInfo.agentDiscount ? key.commonProdInfo.agentDiscount : 100) / 100;
            }
          } else {
            if (vipType == 2) {
              key.price = key.vipDiscount;
            } else if (vipType == 4) {
              key.price = key.svipDiscount;
            } else {
              key.price = key.commonProdInfo && key.commonProdInfo.agentDiscount ? key.commonProdInfo.agentDiscount : key.price;
            }
          }
        }
        key.totalPrice = 0;
        // 链动优惠
        // console.log(!(this.cashBack && this.getUseMcbgId));
        // console.log(this.getUseMcbgId);
        // console.log(this.cashBack);
        key.totalPrice = utilJs.toMyFixed2(key.price * key.quantity * key.dignityDiscount);
        if (this.presale) { // 预售
          key.totalPrice = this.moneyType == 2 ? utilJs.toMyFixed2(this.presale.deposit * key.quantity) : utilJs.toMyFixed2((this.presale.aPrice - this.presale.deposit) * key.quantity)
        } else if (this.isInBargain) { // 砍价优惠计算
          let totalHadBargainPrice = shopList && shopList[0] && shopList[0].totalHadBargainPrice ? shopList[0].totalHadBargainPrice : 0;
          key.totalPrice = utilJs.toMyFixed2(key.totalPrice * 1 - totalHadBargainPrice * 1);
        }
        //计算商品的折后价 (区分链动跟身份折扣)
        shopVipTotlaPrice = 0;
        if (this.shopList.find(item => item.isFromChain == true && item.orderBonus * 1 > 0)) {
          shopVipTotlaPrice = this.shopList.reduce((cPrice, item) => {
            return utilJs.toMyFixed2(cPrice + item.orderBonus * item.quantity);
          }, 0);
        } else {
          shopVipTotlaPrice = shopList.reduce((price, item) => {
            return price + item.price * item.quantity * item.dignityDiscount;
          }, 0);
        }
        freeShipping = key.freeShipping;
        if (key.isCollage) {
          this.isClg = true;
        } else if (key.isFlashSales) {
          this.isSales = true;
        }
        if (this.shopList.length == 1 && key.isFromChain && key.orderBonus && !(this.cashBack && this.getUseMcbgId) && !key.isCollage && !key.isFlashSales && !this.isInBargain && !this.presale) {
          key.chainDiscount = utilJs.toMyFixed2(key.price - key.orderBonus);
          key.totalPrice = utilJs.toMyFixed2(key.orderBonus * key.quantity);
        }
        totalPrice = totalPrice + key.totalPrice;
        // 计算邮费
        arrGodId.push(key.mgId);
        goodList.push({
          mgId: key.mgId,
          quantity: key.quantity || 1,
          gsiiId: key.gsiiId,
        });
      }
      if (localStorage.getItem("SelectAddress")) {
        //从地址列表回来
        let addressInfo = localStorage.getItem("AddressInfo")
          ? JSON.parse(localStorage.getItem("AddressInfo"))
          : {
            addrId: "",
            name: "",
            mobile: "",
            province: "",
            city: "",
            area: "",
            address: "",
            postcode: "",
            status: 2,
          };
        this.addressInfo = {
          addrId: addressInfo.addrId,
          name: addressInfo.name,
          mobile: addressInfo.mobile,
          province: addressInfo.province,
          city: addressInfo.city,
          area: addressInfo.area,
          address: addressInfo.address,
          postcode: addressInfo.postcode,
          isDefult: addressInfo.status == 1,
        };
        this.typeIndex = 1;
      }
      if (this.offlineAddressInfo.name == "" && this.offlineAddressInfo.mobile == "") {
        if (this.addressInfo.name != "" && this.addressInfo.mobile != "" && (!this.mallOfflineUser || (this.mallOfflineUser && this.mallOfflineUser.userName == '' && this.mallOfflineUser.userMobile == ''))) {
          this.offlineAddressInfo.name = this.addressInfo.name;
          this.offlineAddressInfo.mobile = this.addressInfo.mobile;
        } else if (this.mallOfflineUser && this.mallOfflineUser.userName && this.mallOfflineUser.userMobile) {
          this.offlineAddressInfo.name = this.mallOfflineUser.userName;
          this.offlineAddressInfo.mobile = this.mallOfflineUser.userMobile;
        }
      }
      let data = {};
      let url = "";
      if (this.isIntegral == 1) {
        //积分商城
        data = {
          goodsId: this.shopList[0].mgId,
          quantity: this.shopList[0].quantity,
        };
        if (this.goodsRoomId) {
          data.isLive = 1;
          data.socialRoomId = this.goodsRoomId;
        }
        url = `${global.apiurl}pointMall/exchangeConfirm`;
      } else {
        data = {
          goId: goId,
          arrGodId: JSON.stringify(arrGodId),
          addrId: this.addressInfo.addrId,
          goodList: goodList,
          totalPrice: totalPrice,
          orderType: this.shopList && this.shopList[0] && this.shopList[0].presale ? 2048 : this.isInBargain ? 512 : this.shopList && this.shopList[0] && this.shopList[0].isFlashSales == true ? 2 : this.shopList && this.shopList[0] && this.shopList[0].isCollage == true ? 4 : "",
        };
        if (this.goodsRoomId) {
          data.isLive = 1;
          data.socialRoomId = this.goodsRoomId;
        }
        if (this.moneyType && this.moneyType == 3) {
          data.moneyType = 3
        }
        url = `${global.apiurl}goodsOrders/subOrderPage`;
      }
      utilJs.postMethod(url, data, (res) => {
        // 禁止购买
        if (res.code == 301) {
          this.$cjConfirm({
            title: '温馨提示',
            message: '暂无权限购买，请联系管理员~',
            showCancelButton: false,
            onConfirm: () => {
              // 非直播带货
              if (!this.fromLIve) {
                this.$router.go(-1);
              } else {
                this.$emit('closeSettlement');
              }
            }
          });
        }
        if (res.statusCode == 400) {
          this.$routerGo(this, "replace", {
            path: "/error/emptyPage",
            query: {
              from: "MALL",
              info: res.msg,
            },
          });
          return;
        }
        if (res.cashBackStatus != 2 && this.cashBackList.length > 0) {
          this.cashBackList = [];
          this.shopList.forEach((item) => {
            delete item.mcbId;
          });
          this.cashBack = null;
          this.getPayMoney(this.shopList, this.userPoints);
          if (isShowCashBackEnd) {
            this.$showCjToast({
              text: "该满减活动已结束，已按照普通商品结算！",
              type: "warn",
            });
            isShowCashBackEnd = false;
          }
        }
        this.chainInfo = res.chain;
        let addressInfo = res.address;
        this.mallOfflineUser = res.mallOfflineUser;
        if (!localStorage.getItem("SelectAddress")) {
          if (addressInfo == null) {
            this.addressInfo = {
              addrId: "",
              name: "",
              mobile: "",
              province: "",
              city: "",
              area: "",
              address: "",
              postcode: "",
              isDefult: false,
            };
          } else {
            this.addressInfo = {
              addrId: addressInfo.addrId,
              name: addressInfo.name,
              mobile: addressInfo.mobile,
              province: addressInfo.province,
              city: addressInfo.city,
              area: addressInfo.area,
              address: addressInfo.address,
              postcode: addressInfo.postcode,
              isDefult: addressInfo.status == 1,
            };
          }
        }
        if (this.offlineAddressInfo.name == "" && this.offlineAddressInfo.mobile == "") {
          if (this.addressInfo.name != "" && this.addressInfo.mobile != "" && (!this.mallOfflineUser || (this.mallOfflineUser && this.mallOfflineUser.userName == '' && this.mallOfflineUser.userMobile == ''))) {
            this.offlineAddressInfo.name = this.addressInfo.name;
            this.offlineAddressInfo.mobile = this.addressInfo.mobile;
          } else if (this.mallOfflineUser && this.mallOfflineUser.userName && this.mallOfflineUser.userMobile) {
            this.offlineAddressInfo.name = this.mallOfflineUser.userName;
            this.offlineAddressInfo.mobile = this.mallOfflineUser.userMobile;
          }
        }
        if (this.isIntegral == 1) {
          let that = this;
          curUserPoints = Math.floor(res.pMallGood.userPoint * 1);
          if (this.subStatus == 1) {
            this.subStatus = 0;
            if (res.status == 3) {
              this.showIntegralTip();
            } else if (res.status != 0 && res.status != 3) {
              this.$showCjToast({
                text: res.msg,
                type: "warn",
              });
            } else {
              this.$cjConfirm({
                title: '兑换',
                message: `确定花${that.totalAllPrice}${this.customPointName}兑换？`,
                onConfirm: () => {
                   this.mallGoodsExchange();
                }
              });
            }
          }

          this.pMallGood = res.pMallGood;
          this.shopList[0].stock = res.pMallGood.stock < res.pMallGood.limitNum - res.pMallGood.exchangeNum * 1 ? res.pMallGood.stock : res.pMallGood.limitNum - res.pMallGood.exchangeNum * 1;
          this.totalPostage = 0;
        } else {
          curUserPoints = Math.floor(res.user.points * 1);
          this.isInvoice = res.isInvoice;
          this.rmb2Points = res.rmb2Points;
          this.balance = res.user.balance * 1;
          this.couponList = this.presale && ((this.moneyType == 3 && this.enableDeduction == 0) || this.moneyType == 2) ? [] : (res.user.coupon || []);
          this.isAssociatedForm = res.collectPage != 3 && res.collectPage == 1 && res.isRelForm == true && res.hasFormLog == false && localStorage.getItem("showForm") == 1;
          this.totalPostage = (this.isFromSelectAddress == true && res.postage == null) || (this.addressInfo.name == "" && this.addressInfo.mobile == "") ? null : res.postage * 1;
          var date = new Date();
          var year = date.getFullYear();
          var month = date.getMonth() + 1;
          var day = date.getDate();
          for (let i = 0; i < this.couponList.length; i++) {
            let endYear = this.couponList[i].endAt.split(" ")[0].split("-")[0];
            let endMonth = this.couponList[i].endAt.split(" ")[0].split("-")[1];
            let endDay = this.couponList[i].endAt.split(" ")[0].split("-")[2];
            this.couponList[i].endAt = year == Number(endYear) && month == Number(endMonth) && day == Number(endDay) ? "今日到期" : this.couponList[i].endAt;
          }
        }
        this.coinAmount = res.coinAmount;
        this.proportion = res.giftCardConfig && res.giftCardConfig.proportion ? res.giftCardConfig.proportion : 0;
        // let hasDiscount = false;
        // hasDiscount = this.shopList.every(item => item.dignityDis == true);
        // 安卓 iosAPP端、直播间抽奖、大转盘、普通大转盘活动、满减增、砍价、限时购、拼团、使用积分、身份折扣、预售则不参与虚拟支付
        // this.isCanUseGiftCard = res.isCanUseGiftCard && !(utilJs.isAndroidApp() || utilJs.isIOSApp()) && this.livePrizeInfo == null && this.talId == "" && this.isTurntable == false && this.cashBack == null && this.isInBargain == false && !this.isClg && !this.isSales && !this.userPoints && !hasDiscount;
        // this.isCanUseGiftCard =
        //   res.isCanUseGiftCard &&
        //   !(utilJs.isAndroidApp() || utilJs.isIOSApp()) &&
        //   this.livePrizeInfo == null &&
        //   this.talId == '' &&
        //   this.isTurntable == false &&
        //   !this.cashBack &&
        //   this.isInBargain == false &&
        //   this.presale == null;
        // if (this.giftCardInfo.unableMarketing && hasDiscount) {
        //   this.isCanUseGiftCard = false;
        // }
        this.isCanUseGiftCard = this.getIsCanUseGiftCard(res.isCanUseGiftCard);
        this.payConf = res.payConf;
        hasPassword = res.user.hasPassword;
        //从详情或购物车页进入
        let shopList = this.shopList;

        this.buyNow = fromWhere;
        this.freeShipping = freeShipping;
        this.shopList = shopList;
        this.isTurntable = this.shopList[0].isTurntable ? true : false;
        this.isPayAward = this.shopList[0].isPayAward ? true : false;
        this.isGiftRelate = this.shopList[0].isGiftRelate ? true : false;
        this.goodList = res.goodList;
        this.getPayMoney(this.shopList, this.userPoints);
      });
      //获取线下自提信息
      if ((this.deliverType == 3 || this.deliverType == 2) && this.numOperate == false) {
        this.getOffline();
      }
      console.log("typeIndex:" + this.typeIndex);
    },
    // 判断是否可以使用虚拟币支付
    getIsCanUseGiftCard(isCanUseGiftCard) {
      let flag = isCanUseGiftCard;
      if (flag) {
        if (utilJs.isAndroidApp() || utilJs.isIOSApp() || this.livePrizeInfo || this.isTurntable || this.cashBack || this.isInBargain || this.presale) {
          flag = false;
        }
        const hasDiscount = this.shopList.every(item => item.dignityDis == true);
        const hasChainDiscount = this.shopList.every(item => item.chainDiscount && item.chainDiscount > 0);
        // 后台设置不叠加营销活动 则参与优惠就不展示虚拟币支付 身份折扣 || 链动折扣
        if (this.giftCardInfo.unableMarketing && (hasDiscount || hasChainDiscount)) {
          flag = false;
        }
      }
      console.log('getIsCanUseGiftCard', flag);
      return flag;
    },
    // 获取商城服务协议
    getProdProtocol() {
      utilJs.getMethod(`${global.apiurl}protocols/getProtocolByProdType?prodType=12`, (res) => {
        this.protocolInfo = res.protocol && res.protocol.length > 0 ? res.protocol : null;
        this.isCheckAgreement = res && res.relatesType == 1 ? true : false;
        if (isCheckAgreement != -1) {
          this.isCheckAgreement = isCheckAgreement == 1 ? true : false;
        }
      });
    },
    changeCheckAgreement() {
      this.isCheckAgreement = !this.isCheckAgreement;
      isCheckAgreement = this.isCheckAgreement ? 1 : 0;
    },
    goForm() {
      let pathQuery = {
        cId: -1,
        extId: this.shopList[0].mgId,
        ckFrom: global.ckFrom.shopping,
        isFromInvite: 0,
        pId: this.shopList[0].pId,
        relType: 19,
        type: 1,
        recRelateId: this.$route.query.recRelateId,
        recType: this.$route.query.recType,
        isGoBack: 1,
      };
      if (this.goodsRoomId) {
        pathQuery.goodsRoomId = this.goodsRoomId;
      }
      this.$routerGo(this, "push", { path: "/homePage/form", query: pathQuery }); //type==1表示关联表单
    },
    //提交订单
    submitOrder() {
      if (isClick) {
        return;
      }
      isClick = true;
      let goods = [];
      this.isSales = false;
      this.isClg = false;
      console.log(this.shopList)
      for (let key of this.shopList) {
        let itemT = {
          mgId: key.mgId,
          quantity: key.quantity || 1,
          gsiiId: key.gsiiId,
          postage: this.presale && this.moneyType == 2 ? 0 : this.typeIndex == 2 ? 0 : key.postage,
          deductedPoints: this.userPoints ? key.deductedPoints : 0,
          deductedMoney: this.userPoints ? key.deductedMoney : 0,
          amount: key.amount,
          subSpecs: key.shopSpecInfo,
          type: key.isCollage ? 4 : key.isFlashSales ? 2 : 1,
          pId: key.pId,
          isMallExpressDeliver: this.typeIndex == 1 ? 1 : -1,
          isMallOfflineDeliver: this.typeIndex == 2 ? 1 : -1,
          relData: key.relData,
          subProdId:key.subProdId,
          subSonProdId:key.subSonProdId
        };
        if (key.isFlashSales) {
          this.isSales = true;
        }
        if (key.isCollage) {
          this.isClg = true;
          itemT.groupId = key.groupId;
          itemT.mallCollageId = key.mallCollageId;
        }
        goods.push(itemT);
      }
      // 符合满减活动的赠送商品，将商品数据存入goods
      if (this.cashBack != null && this.getUseMcbgId != null && this.getUseMcbgId.isSendProd == 1) {
        for (let key of this.getUseMcbgId.sendProdList) {
          if (key.stock > 0) {
            let itemT = {
              mgId: key.prodId,
              quantity: key.stock - key.number * this.getCashBackLoop >= 0 ? key.number * this.getCashBackLoop : key.stock,
              gsiiId: key.gsiiId || null,
              postage: this.typeIndex == 2 ? 0 : key.postage,
              deductedPoints: this.userPoints ? key.deductedPoints : 0,
              deductedMoney: this.userPoints ? key.deductedMoney : 0,
              amount: 0,
              subSpecs: key.shopSpecInfo || "",
              type: key.isCollage ? 4 : key.isFlashSales ? 2 : 1,
              pId: key.pId,
              isMallExpressDeliver: this.typeIndex == 1 ? 1 : -1,
              isMallOfflineDeliver: this.typeIndex == 2 ? 1 : -1,
              isGift: 1,
              relData: key.relData,
            };
            goods.push(itemT);
          }
        }
      }
      goodsType = this.presale ? 2048 : this.isClg ? 4 : this.isSales ? 2 : 1; // 预售2048
      let data = {
        mail: this.isMail ? this.email : "",
        goId: null,
        msg: this.msg,
        buyNow: this.buyNow,
        payMoney: (this.payType == 2 && (this.isCanUseGiftCard && this.giftCardInfo.unableMarketing)) ? this.allOriginalPrice : this.totalAllPrice,
        userAddressId: this.addressInfo.addrId,
        deductedPoints: (this.payType == 2 && this.giftCardInfo.unableMarketing) ? 0 : (this.userPoints ? this.totalPoints : 0),
        deductedMoney: (this.payType == 2 && this.giftCardInfo.unableMarketing) ? 0 : (this.userPoints ? this.totalPointsPrice : 0),
        deductedCouponPrice: (this.payType == 2 && this.giftCardInfo.unableMarketing) ? 0 : this.deductedCouponPrice,
        postage: this.presale && this.moneyType == 2 ? 0 : this.deliverType == 2 || (this.deliverType == 3 && this.typeIndex == 2) ? 0 : this.totalPostage || 0, //防止null后台数据统计问题
        goods: goods,
        invoiceData: this.invoiceInfo,
        type: goodsType,
        useCoupon: (this.choosedCouponIndex == -1 || this.cashBack != null || (this.payType == 2 && this.giftCardInfo.unableMarketing)) ? "" : this.couponList[this.choosedCouponIndex].eRcdId,
        redeemCodeId: (this.choosedCouponIndex == -1 || this.cashBack != null || (this.payType == 2 && this.giftCardInfo.unableMarketing)) ? "" : this.couponList[this.choosedCouponIndex].redeemCodeId,
        payMethod: this.payType == 0 ? 1 : this.payType == 2 ? 14 : (this.payType == 3 ? 20 : 2),
        talId: this.talId,
        palId: this.$route.query.palId || "",
        userName: this.typeIndex == 1 ? this.addressInfo.name : this.offlineAddressInfo.name,
        userMobile: this.typeIndex == 1 ? this.addressInfo.mobile : this.offlineAddressInfo.mobile,
        modId: this.nearOffline && this.nearOffline.modId ? this.nearOffline.modId : "",
        deliverType: this.deliverType == 2 || (this.deliverType == 3 && this.typeIndex == 2) ? 2 : 1,
        cashBackAmount: (this.payType == 2 && (this.isCanUseGiftCard && this.giftCardInfo.unableMarketing)) ? 0 : (this.cashBack ? this.cashBack.reduce : 0), // 满减优惠金额
        fromRoute: fromRoute,
        relData: this.relData,
      };
      // 判断预售 preId 预售活动的Id relId 预售活动关联的Id moneyType   预售付款类型：1= 普通类型；2=定金；3=尾款  （不是预售的不用传，我这边默认值1了）
      // 关于尾款需要再多传一个字段 mainOrderId   主订单Id （尾款需要记录）
      if (this.shopList[0] && this.presale) {
        data.preId = this.presale.preId;
        data.relId = this.presale.relId;
        data.moneyType = this.moneyType;
      }
      if (this.shopList[0] && this.presale && this.moneyType == 3) {
        data.mainOrderId = this.presale.mainOrderId
      }
      if (this.goodsRoomId) {
        data.subProdId = this.goodsRoomId;
        data.subProdType = 51;
      }
      // 当前为大转盘类型得type
      if (this.shopList[0] && this.shopList[0].isTurntable == true) {
        data.type = 16;
      }
      // 当前为支付有礼传过来得类型
      if (this.shopList[0] && this.shopList[0].isPayAward == true) {
        data.type = 32;
      }
      // 当前为礼包过来得类型
      if (this.shopList[0] && this.shopList[0].isGiftRelate == true) {
        data.type = 1024;
        data.grId = this.$route.query.grId;
      }
      // 兑换券兑换商品
      if (this.shopList[0] && this.shopList[0].isExchange) {
        data.type = 4096;
        data.rcdId = this.$route.query.rcdId;
      }
      //直播抽奖类型是64
      if (this.livePrizeInfo && this.livePrizeInfo.activityType == 1) {
        data.type = 64;
        this.livePrizeInfo.prizeId && (data.talId = this.livePrizeInfo.prizeId);
        if (this.livePrizeInfo.rId) {
          //抽奖有额外
          data.rId = this.livePrizeInfo.rId;
        }
      }
      //直播福利类型128
      if (this.livePrizeInfo && this.livePrizeInfo.activityType == 2) {
        data.type = 128;
        this.livePrizeInfo.prizeId && (data.talId = this.livePrizeInfo.prizeId);
        if (this.livePrizeInfo.rId) {
          //福利有额外
          data.rId = this.livePrizeInfo.rId;
        }
      }
      //直播大转盘16
      if (this.livePrizeInfo && this.livePrizeInfo.activityType == 3) {
        data.type = 16;
        this.livePrizeInfo.prizeId && (data.talId = this.livePrizeInfo.prizeId);
      }
      //达人邀请类型奖励 256
      if (this.livePrizeInfo && this.livePrizeInfo.activityType == 4) {
        data.type = 256;
        this.livePrizeInfo.prizeId && (data.talId = this.livePrizeInfo.prizeId);
      }
      if (this.shopList[0] && this.shopList[0].isFromInteract) {
        data.subProdId = this.shopList[0].interactDetailId;
        data.subProdType = 151;
      }
      // 商城砍价
      if (this.isInBargain) {
        data.type = 512;
      }
      if (!(this.cashBack && this.getUseMcbgId) && !this.isInBargain && this.shopList[0].isFromChain && this.shopList[0].orderBonus && Number(this.shopList[0].chainDiscount) > 0) {
        data.chainDiscountMoney = Number(this.shopList[0].price) - Number(this.shopList[0].orderBonus)
      }
      let _this = this;
      _this.orderType = data.type;
      if (sessionStorage.getItem("promotedAccountId")) {
        data.promotedAccountId = sessionStorage.getItem("promotedAccountId");
        localStorage.setItem("promotedAccountId", sessionStorage.getItem("promotedAccountId"));
      }
      //携带当前进入的时候的分享人id过去后端做数据分析
      const xTraceSid = sessionStorage.getItem('shareFromUserId') || '';
      if (xTraceSid) {
        data['x-trace-sid'] = xTraceSid;
      }
      utilJs.postMethod(
        global.apiurl + "goodsOrders/submitOrder",
        data,
        (res) => {
          isClick = false;
          this.isSubMch = this.payType == 0 ? res.isSubMch : 0;
          this._liveId = res.liveId || "";
          this._playType = res.playType || "";
          this._socialType = res.socialType || "";
          this._detailId = res.subSonProdId || "";
          goId = res.orderId;
          isGetOrder = goId;
          //直播领奖跳转而来，提交后清空状态
          if (this.livePrizeInfo) {
            this.$store.commit("live/setPrizeInfo", null); //清空prizeInfo的信息
          }
          if (res.code == 201) {
            // 生成新得订单则去除状态订单号值
            this.$store.commit('updateOrderDetailNo', '');
            this.$showCjToast({
              text: this.shopList[0] && this.shopList[0].isExchange ? "兑换成功" : "支付成功",
              type: "success",
            }).then(() => {
              _this.getGuideData();
            });
            return;
          }
          if (this.payType == 1) {
            this.showPassword = true;
          } else if (this.payType == 2) {
            this.mallGiftCardPay(goId);
          } else if (this.payType == 3) { // 支付宝支付
            this._aLiPay(goId).then(res => {
              // 生成新得订单则去除状态订单号值
              this.$store.commit('updateOrderDetailNo', '');
              let routeType = this.goodsRoomId ? 'push' : 'replace'; //mp和mplive共用改组件，路由跳转不一样
              this.$routerGo(this, routeType, { path: "/homePage/course/aliPayMiddlePage", query: { orderId: res.orderNo } });
            })
          } else {
            this.wechatPay();
          }
        },
        (failRes) => {
          isClick = false;
        }
      );
    },
    _aLiPay(orderId) {
      return new Promise((resolve, reject) => {
        utilJs.postMethod(
          global.apiurl + 'payment/alipayConf',
          { goId: orderId },
          res => {
            resolve(res);
          },
          () => {
            reject();
          }
        );
      });
    },
    addNum(item) {
      this.numOperate = true;
      isAutoChooseCoupon = true;
      this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
      this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
      this.getOrderInfo();
    },
    subNum(item) {
      this.numOperate = true;
      isAutoChooseCoupon = true;
      this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
      this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
      this.getOrderInfo();
    },
    inputChange(item) {
      return new Promise((resolve) => {
        this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
        this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
        resolve();
      });
    },
    finishInput(e) {
      this.inputChange(e).then(() => {
        this.getOrderInfo();
      });
    },
    cashListAddNum(item) {
      this.numOperate = true;
      isAutoChooseCoupon = true;
      this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
      this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
      this.getOrderInfo();
    },
    cashListSubNum(item) {
      this.numOperate = true;
      isAutoChooseCoupon = true;
      this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
      this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
      this.getOrderInfo();
    },
    cashListInputChange(item) {
      return new Promise((resolve) => {
        this.$set(this.shopList[item.itemIndex], "quantity", item.inputNumber);
        this.$set(this.shopList[item.itemIndex], "totalPrice", utilJs.toMyFixed2(item.inputNumber * this.shopList[item.itemIndex].price * this.shopList[item.itemIndex].dignityDiscount));
        resolve();
      });
    },
    cashListFinishInput(e) {
      this.cashListInputChange(e).then(() => {
        this.getOrderInfo();
      });
    },
    clickSettlement(e) {
      if (this.isCheckAgreement == false && this.protocolInfo) {
        this.$showCjToast({
          text: "请勾选协议后提交订单",
          type: "warn",
        });
        return;
      }
      // 判断体验版是否到期，到期之后不可购买商品
      if (utilJs.alertShopExpire(this, utilJs.getTimeByDate(this.companyAuth.expireTime))) return true;
      // 判断是否关联表单
      if (this.isAssociatedForm) {
        this.goForm();
        return;
      }
      //点击结算
      if (!this.addressInfo.name && !this.addressInfo.mobile && this.typeIndex == 1) {
        this.$showCjToast({
          text: "请选择收货地址",
          type: "warn",
        });
        return;
      }
      if (this.offlineAddressInfo.name == "" || (this.offlineAddressInfo.mobile == "" && this.typeIndex == 2)) {
        this.$showCjToast({
          text: "请添加提货人信息",
          type: "warn",
        });
        return;
      }
      if (this.isMail && !utilJs.isEmail(this.email)) {
        this.$showCjToast({
          text: "请填写正确的邮箱",
          type: "warn",
        });
        return;
      }
      if (this.isIntegral == 1) {
        this.subStatus = 1;
        this.getOrderInfo();
      } else {
        this.isShowPay = true;
      }
    },
    //积分兑换
    mallGoodsExchange() {
      if (isClick) {
        return;
      }
      let that = this;
      isClick = true;
      let data = {
        goodsId: this.shopList[0].mgId,
        quantity: this.shopList[0].quantity,
        userAddressId: this.addressInfo.addrId,
        msg: this.msg,
        userName: this.typeIndex == 1 ? this.addressInfo.name : this.offlineAddressInfo.name,
        userMobile: this.typeIndex == 1 ? this.addressInfo.mobile : this.offlineAddressInfo.mobile,
        modId: this.nearOffline && this.nearOffline.modId ? this.nearOffline.modId : "",
        postageType: this.deliverType == 2 || (this.deliverType == 3 && this.typeIndex == 2) ? 1 : 0,
        fromApp: 'oa'
      };
      utilJs.postMethod(
        `${global.apiurl}pointMall/mallGoodsExchange`,
        data,
        (res) => {
          that.$showCjToast({
            text: "兑换成功！",
            type: "success",
          }).then(() => {
            that.$router.go(-1);
          });
          isClick = false;
        },
        (failRes) => {
          isClick = false;
        }
      );
    },
    //点击支付
    clickPayType(payType) {
      this.payType = payType;
      //未设置密码 && 余额支付 && 支付价格不为0
      if (hasPassword == 0 && this.payType == 1 && Number(this.totalAllPrice) != 0) {
        this.$routerGo(this, "push", { path: "/member/scholarship/updatePassword" });
        return;
      }
      // 小程序环境不能跳充值页面
      if (this.$isWxApp() && this.payType == 2 && this.totalCoin > this.coinAmount) {
        return
      }
      if (this.payType == 2 && this.totalCoin > this.coinAmount) { // 选择虚拟币支付，且虚拟币余额不足，则跳到虚拟币充值页面
        if (this.fromLIve) {
          this.$routerGo(this, "push", { path: "/member/giftCard/rechargeCard?rechargeFrom=1" });
        } else {
          let query = this.$route.query || {};
          sessionStorage.setItem('giftCardBack', JSON.stringify(query))
          this.$routerGo(this, "replace", { path: "/member/giftCard/rechargeCard" });
        }
        return;
      }
      if (isGetOrder == 0 || !isGetOrder) {
        // 还未下订单走订单提交
        this.submitOrder();
      } else {
        if (this.payType == 1) {
          this.showPassword = true;
        } else if (this.payType == 2 || this.payType == 3) {
          this.submitOrder();
        } else {
          this.wechatPay();
        }
      }
    },
    // 选择虚拟币支付
    mallGiftCardPay(goId) {
      if (isPayGiftCard) return;
      isPayGiftCard = true;
      utilJs.postMethod(`${global.apiurl}payment/mallGiftCardPay`, { goId: goId }, (res) => {
        let that = this;
        isPayGiftCard = false;
        that.useCoinPay = true;
        that.isShowPay = false;
        that.$showCjToast({
          text: "支付成功",
          type: "success",
        }).then(() => {
          // 生成新得订单则去除状态订单号值
          that.$store.commit('updateOrderDetailNo', '');
          that.getGuideData();
        });
      });
    },
    //选择微信支付
    wechatPay() {
      let _this = this;
      let u = navigator.userAgent;
      let isAndroid = u.indexOf("APPLogin") > -1; //android终端
      let isiOS = u.indexOf("IOSLogin") > -1 || u.indexOf("IOSNewLogin") > -1 || navigator.userAgent.indexOf("IOSNewApp") > -1; //ios终端
      if (isAndroid == true || isiOS == true) {
        let backUrl = window.location.href.split("#")[0] + "#/member/myOrder/allOrderList";
        utilJs.appPay({ orderId: goId }, 0, 0, 0, 2, backUrl);
      } else {
        if (isWechatPaying) {
          return;
        }
        isWechatPaying = true;
        let data = { goId: goId };
        let isWechatH5Pay = !utilJs.isWeiXin() && utilJs.isMobileUserAgent() && !utilJs.isIOSAppALL() && !utilJs.isAndroidApp();
        if (isWechatH5Pay) {
          let payFromPath = window.location.href.split("#")[0] + "#" + (this.pathFrom || "/");
          localStorage.setItem("payFromPath", payFromPath);
          data.goUrl = window.location.href.split("#")[0] + "#" + this.$route.fullPath + "&isWechatH5Pay=1";
        } else if (this.isSubMch == 1 || this.$isWxApp()) {
          data.goUrl = window.location.href.split("#")[0] + "#/mall/shopSettlement/shopSettlement?isGoldPlan=1";
          let prodIdArr = [];
          for (let item of this.shopList) {
            prodIdArr.push(item.mgId);
          }
          this.prodId = prodIdArr.toString();
          let ls = {
            goId: goId,
            orderType: this.orderType,
            totalAllPrice: this.totalAllPrice,
            givenPoints: givenPoints,
            payType: this.payType,
            isSubMch: this.isSubMch,
            liveId: this._liveId || "",
            goodsRoomId: this.goodsRoomId || "",
            socialType: this._socialType || "",
            detailId: this._detailId || "",
            playType: this._playType || "",
          };
          if (this.orderType == 1 || this.orderType == 2) {
            ls.prodId = this.prodId;
          }
          localStorage.setItem("shopPayBack", JSON.stringify(ls));
        }
        utilJs.wechatMallPay(
          data,
          (res) => {
            // 生成新得订单则去除状态订单号值
            _this.$store.commit('updateOrderDetailNo', '');
            isWechatPaying = false;
            _this.getGuideData();
          },
          (fres) => {
            localStorage.removeItem("shopPayBack");
            isWechatPaying = false;
            console.log("取消支付");
          }
        );
      }
    },
    hidePwd() {
      this.showPassword = false;
    },
    confirmPwd(pwd) {
      let _this = this;
      let data = { goId: goId, payPwd: pwd };
      if (sessionStorage.getItem("promotedAccountId")) {
        data.promotedAccountId = sessionStorage.getItem("promotedAccountId");
      }
      //余额支付
      utilJs.yueMallPay(data, (res) => {
        this.$showCjToast({
          text: "支付成功",
          type: "success",
        }).then(() => {
          // 生成新得订单则去除状态订单号值
          _this.$store.commit('updateOrderDetailNo', '');
          _this.getGuideData();
        });
      });
    },
    //点金计划，检查是否直播带货，是的话支付成功要跳转回直播间
    checkLiveGoods(pathStr) {
      let path = pathStr || this.pathFrom;
      if (this.isSubMch == 1 && this.goodsRoomId && this._socialType) {
        let goPath = this._playType == 2 ? "liveVerticalRoom" : "liveRoom";
        path = `/homePage/live/${goPath}?liveId=${this._liveId}&SocialRoomId=${this.goodsRoomId}`;
        //社群带货跳社群
        path = this._socialType == 1 ? `/homePage/socialGroup/chatRoom?SocialRoomId=${this.goodsRoomId}` : path;
        //独立直播间
        path = this._socialType == 4 ? `/homePage/live/liveVHRoom?liveId=${this._liveId}&SocialRoomId=${this.goodsRoomId}&detailId=${this._detailId}` : path;
      }
      return path;
    },
    // 支付有礼
    getGuideData() {
      let _this = this;
      let prodIdArr = [];
      if (_this.orderType == 1 || _this.orderType == 2 || (_this.orderType == 2048 && this.moneyType == 3)) {
        if (!(this.$route.query.isGoldPlan == 1 && this.prodId != "")) {
          for (let item of this.shopList) {
            prodIdArr.push(item.mgId);
          }
          this.prodId = prodIdArr.toString();
        }
        utilJs.getMethod(
          global.apiurl + "common/getGuideData?prodId=" + this.prodId + "&prodType=" + global.ckFrom.shopping,
          function (res) {
            _this.guideData = res;
            if (_this.guideData.isNeedShowPayPage == 1 || _this.guideData.isOpenGuide == 1) {
              //跳转记录本地store，sessionStorage
              if (_this.goodsRoomId) {
                let goPath = _this._playType == 2 ? "liveVerticalRoom" : "liveRoom";
                path = `/homePage/live/${goPath}?liveId=${_this._liveId}&SocialRoomId=${_this.goodsRoomId}`;
                //独立直播间
                path = _this._socialType == 4 ? `/homePage/live/liveVHRoom?liveId=${_this._liveId}&SocialRoomId=${_this.goodsRoomId}&detailId=${_this._detailId}` : path;
                _this.$store.commit('live/setRecommendLiveInfo', path);
                sessionStorage.setItem('setRecommendLiveInfo', path);
              }
              let path = `/homePage/payPolitely/payPolitely?orderId=${goId}&prodType=${global.ckFrom.shopping}`;
              path = _this.checkLiveGoods(path);
              _this.$routerGo(_this, "replace", { path: path });
            } else {
              _this.paySuccessCallBack();
            }
          },
          (failRes) => {
            _this.paySuccessCallBack();
          }
        );
      } else {
        _this.paySuccessCallBack();
      }
    },
    paySuccessCallBack() {
      this.showPassword = false;
      this.isShowPay = false;
      if (localStorage.getItem("promotedAccountId")) {
        sessionStorage.setItem("promotedAccountId", localStorage.getItem("promotedAccountId"));
        localStorage.removeItem("promotedAccountId");
      }
      if (this.isClg) {
        let path = `/homePage/collage/collageDetail?isMall=1&orderId=${goId}`;
        path = this.checkLiveGoods(path);
        this.$routerGo(this, "replace", { path: path });
        return;
      }
      if (givenPoints && givenPoints > 0 && goodsType == 1 && this.payType != 2) {
        //当支付赠送积分大于0，且是普通商品且不是虚拟币支付，跳转到支付成功赠送积分页面
        let payInfo = {
          price: this.totalAllPrice,
          givenPoints: givenPoints,
          goId: goId,
          useCoinPay: this.useCoinPay
        };
        sessionStorage.setItem('payInfo', JSON.stringify(payInfo));
        let path = `/homePage/payPolitely/payPolitely?orderId=${goId}&prodType=${global.ckFrom.shopping}&payInfo=1`;
        this.$routerGo(this, 'replace', { path: path });
        return;
      }
      if (this.fromPage == "SHOP") {
        let path = "/member/myOrder/allOrderList";
        path = this.checkLiveGoods(path);
        this.$routerGo(this, "replace", { path: path });
        return;
      }
      isGetOrder = 0;
      this.$emit("payMallSuccess");
    },
    clickSelectAddress(e) {
      this.isFromSelectAddress = true;
      if (this.fromPage == "SHOP") {
        this.$routerGo(this, "push", { path: "/mall/shippingAddress/addressList" });
        return;
      }
      this.$emit("clickOpenAddressList");
    },
    closePay: function () {
      if (goId) {
        let that = this;
        that.$cjConfirm({
          title: "请尽快完成支付，逾期可能会错过该商品哦",
          titleCenter: true, //标题是否居中
          message: "",
          messageCenter: true, //内容是否居中
          showMasker: true, //是否显示透明背景
          clickCloseModal: false, //是否点击透明背景关闭弹窗
          showCancelButton: true, //是否显示取消按钮
          cancelButtonText: "稍后支付", //取消按钮文本
          confirmButtonText: "继续支付", //确认按钮文本
          onConfirm() { },
          onCancel() {
            that.isShowPay = false;
            if (that.fromPage != "SHOP") {
              isGetOrder = 0;
              that.$emit("cancelPay");
              return;
            }
            that.$routerGo(that, "replace", {
              path: "/mall/mallOrder/orderDetail",
              query: {
                goId: that.presale && that.presaleGoId ? that.presaleGoId : isGetOrder,
              },
            });
          },
        });
      } else {
        this.isShowPay = false;
      }
    },
    // 获取当前vipType在计算订单信息
    getVipType() {
      utilJs.getMethod(`${global.apiurl}redeemCodes/getVipType`, (res) => {
        this.vipType = res.vipType;
        localStorage.setItem(`vipType${localStorage.getItem("userId")}`, this.vipType);
        this.getOrderInfo(goId);
      });
    },
    //分享
    wechatShare: function () {
      let shareUrl = window.location.href.split("#")[0] + "#/?refereeId=" + localStorage.getItem("userId");
      utilJs.wechatConfig(shareUrl, "", "", "", function () { }, true);
    },
    //手机端分享
    appShare: function () {
      var shareUrl = window.location.href.split("#")[0] + "#/?refereeId=" + localStorage.getItem("userId");
      utilJs.appShareTrue("", "", shareUrl, "");
    },
  },
  created() {
    console.log("-shopSettlement--created---", this.fromPage, this.livePrizeInfo);
    if (this.fromPage != "SHOP") {
      return;
    }
    utilJs.appShare(this);
  },
  mounted() {
    if (this.livePrizeInfo) {
      this.initData();
    }
  },
  activated() {
    if (this.fromPage == "SHOP") {
      setDocumentTitle("订单结算");
      this.wechatShare();
    }
    this.presaleGoId = this.$route.query.goId ? this.$route.query.goId : ''
    if (this.$route.query.isWechatH5Pay == 1 && localStorage.getItem("payFromPath")) {
      let payFromPath = localStorage.getItem("payFromPath");
      localStorage.removeItem("payFromPath");
      window.location.replace(payFromPath);
      return;
    } else if (this.$route.query.isGoldPlan == 1 && localStorage.getItem("shopPayBack")) {
      //微信支付后点击回到这个页面
      let ls = JSON.parse(localStorage.getItem("shopPayBack"));
      goId = ls.goId;
      this.orderType = ls.orderType;
      if (this.orderType == 1 || this.orderType == 2) {
        this.prodId = ls.prodId;
      }
      this.isSubMch = ls.isSubMch;
      this._liveId = ls.liveId || "";
      this.goodsRoomId = ls.goodsRoomId || "";
      this._socialType = ls.socialType || ""; //群类型: 1普通社群，2直播社群,  3是小班课, 4个人直播间
      this._detailId = ls.detailId || "";
      this._playType = ls.playType || "";
      this.totalAllPrice = ls.totalAllPrice;
      givenPoints = ls.givenPoints;
      this.payType = ls.payType;
      localStorage.removeItem("shopPayBack");
      this.getGuideData();
      return;
    } else if (localStorage.getItem("shopPayBack")) {
      localStorage.removeItem("shopPayBack");
    }
    if (localStorage.getItem("promotedAccountId")) {
      localStorage.removeItem("promotedAccountId");
    }
    this.relData = [];
    this.prodId = "";
    goId = "";
    isClick = false;
    isWechatPaying = false;
    this.showInvoice = false; //开发票弹窗
    this.showPassword = false;
    this.isShowPay = false;
    this.isMail = false;
    this.vipType = -1;
    this.couponList = [];
    canUseCoupon = [];
    this.showCoup = false;
    this.deductedCouponPrice = 0;
    this.totalPostage = null;
    this.isTurntable = false; //大转盘标识
    this.isAssociatedForm = false;
    this.isPayAward = false;
    this.useCoinPay = false;
    this.isGiftRelate = false;
    this.isIntegral = this.$route.query.fromIntegral ? this.$route.query.fromIntegral : 0;
    this.goodsRoomId = this.$route.query.goodsRoomId || this.socialRoomId || "";
    this.talId = this.$route.query.talId || "";
    this.pMallGood = {};
    this.isInBargain = this.$route.query.orderType == 512 ? true : false;
    shopAllList = sessionStorage.getItem("shopBuyInfo") ? JSON.parse(sessionStorage.getItem("shopBuyInfo")) : [];
    this.shopList = [];
    this.cashBackList = [];
    this.isSubMch = 0;
    this.showInvoice = false;
    this.invoiceInfo = null;
    this.chainInfo = '';
    this.cashBackList = shopAllList.filter((item) => {
      return item.mcbId != null;
    });
    for (let item of shopAllList) {
      if (item.mcbId) {
        for (let mItem of item.products) {
          this.shopList.push(mItem);
        }
      } else {
        this.shopList.push(item);
      }
    }
    if (this.shopList.length >= 1) {
      // 获取商品预售款项
      this.moneyType = this.shopList[0].moneyType || 1;
      // 获取商品预售数据
      this.presale = this.shopList[0].presale || null;
      this.typeIndex = this.shopList[0].presale && localStorage.getItem('mod') ? 2 : this.typeIndex;
      this.enableDeduction = this.shopList[0].enableDeduction || 0;
      // 满减活动商品和普通商品的配送类型计算
      let isAllExpress = this.shopList.every((item) => item.isMallExpressDeliver === 1);
      let isAllOffline = this.shopList.every((item) => item.isMallOfflineDeliver === 1);
      this.deliverType = isAllOffline == true && isAllExpress == false ? 2 : isAllOffline == true && isAllExpress == true ? 3 : 1;
      let mgId = [];
      if (this.shopList && this.shopList.length > 0) {
        this.shopList.forEach((item) => {
          item.defaultPrice = item.price
          if (this.isIntegral == 1) {
            item.totalPrice = item.quantity * item.price;
          }
          mgId.push(item.mgId);
          if (item.relData) {
            this.relData = [...this.relData, ...item.relData];
          }
        });
      }
      // this.relData = utilJs.unique(this.relData);
      localStorage.setItem("shopMgId", JSON.stringify(mgId));
    }
    //积分商城兑换实体的时候，进入获取不到所需总积分bug处理
    this.payType = 0;
    this.isClg = false;
    this.isSales = false;
    this.numOperate = false;
    this.isFirstChooseCoupon = true;
    this.choosedCouponIndex = -1;
    this.choosedCouponPrice = 0;
    this.goodList = [];
    this._productPriceArrForSingle = []; //每种商品优惠以后，每种商品单个价格
    isShowCashBackEnd = true;
    if (!checkEnableModule(global.ckFrom.mall, this)) {
      return;
    }
    this.getVipType();
    this.getProdProtocol();
    //积分卡获取（第二次读取本地存储)
    utilJs.getGiftCardInfo(1).then(res => {
      this.giftCardInfo = res;
    })
  },
  deactivated() {
    localStorage.removeItem("SelectAddress");
    isCheckAgreement = -1;
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style scoped>
.img-defult-address {
  position: absolute;
  right: 2rem;
  width: 3rem;
  height: 3rem;
}
.input-message {
  height: 100%;
  border: 0;
  background: none;
  outline: none;
  padding-left: 0.5rem;
}
.input:focus {
  outline: none;
}

.shop-cart-bottom {
  position: fixed;
  bottom: 0;
  width: 100%;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  -webkit-align-items: center;
  max-width: 640px;
  z-index: 11;
  left: 0;
  right: 0;
  border-top: 1px solid #ebebeb;
  margin: 0 auto;
}
.content {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 1003;
  background-color: #fff;
}
.c-bg-coupon {
  background-color: #f4f7f9;
}
.close {
  position: absolute;
  right: 0.6rem;
  top: 0.4rem;
}
.masker {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1002;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}
.exchange-left {
  background: url("../../../../public/i/wap/coupon/coupon_left.png") no-repeat
    100%;
  background-size: 100% 100%;
}
.all-coupon-bg {
  background-color: #f4f7f9;
}
.c-mt-2 {
  margin-top: -0.05rem;
}
.c-br-tr4 {
  border-top-right-radius: 0.1rem;
}
.c-br-tl4 {
  border-top-left-radius: 0.1rem;
}
.typeIndex0,
.typeIndex1 {
  position: relative;
}
.typeIndex0::after {
  position: absolute;
  content: "";
  border-bottom: 2.3rem solid #fff;
  border-right: 1.2rem solid transparent;
  right: -1.18rem;
  top: 0;
  z-index: 10;
  border-top-left-radius: 0.1rem;
}
.typeIndex1::after {
  position: absolute;
  content: "";
  border-bottom: 2.3rem solid #fff;
  border-left: 1.2rem solid transparent;
  left: -1.175rem;
  top: 0;
  z-index: 10;
  border-top-right-radius: 0.1rem;
}
.inputInfo::placeholder {
  color: #999;
}
.c-mr-12 {
  margin-right: -0.3rem;
}
.masker-content {
  background-color: #fff;
  max-height: 7.85rem;
  height: 7.85rem;
  width: 100%;
}
.c-fc-lorange {
  color: #ff300c;
}
.tagBg {
  background-color: rgba(255, 48, 12, 0.1);
}
.c-ww136 {
  width: 3.4rem;
}
.c-ww72 {
  width: 1.8rem;
}
.c-bg-f457 {
  background-color: #f4f5f7;
}
.line1 {
  position: absolute;
  content: "";
  height: 0.8rem;
  width: 0.05rem;
  left: 0.125rem;
  top: 0.25rem;
}
.line2 {
  position: absolute;
  content: "";
  height: 0.8rem;
  width: 0.05rem;
  left: 0.125rem;
  bottom: 0.25rem;
}
</style>
